17.5---Zhu Ji Nanxiong manifold, four slots, Red Yellow green Blue (CC150)

Source: Internet
Author: User

Idea: Pay attention to, find a guess when nothing to do, direct statistics, find false guess is also first regardless, and then the result minus guess can.

 Public Static int[] Calcresult (String A, string b) {int[] res =New int[2]; StringBuffer S1=NewStringBuffer (a); StringBuffer S2=NewStringBuffer (b);  for(inti = 0; I < s1.length (); i++){            if(S1.charat (i) = =S2.charat (i)) {res[0]++; }        }         for(inti = 0; I < S2.length (); i++){            if(S1.indexof (S2.substring (i, i+1))! =-1) {res[1]++; S1.deletecharat (S1.indexof (s2.substring (i, I+1))); }} res[1] = res[1]-res[0]; returnRes; }
View Code

17.5---Zhu Ji Nanxiong manifold, four slots, Red Yellow green Blue (CC150)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.