Find the characters with the least frequency in the string and remove them.

Source: Internet
Author: User

It seems that it was a written test question from a company that was written earlier. I can't quite remember it. It seems that I wrote a complete version when I came back that night, but now I remember to write a small note.

Alas, it's hard to find a job now. You have no relevant project experience or internship experience. You have been sentenced to death for recent graduates and non-prestigious graduates! Don't say you have a good foundation! Willing to suffer! Hard work! I love to work overtime! Nobody birds you! It cannot afford to hurt ~

Okay, let's talk about the question:

The idea is that the string is only in English. That's simple. We can check the ASCII table. We can see that the decimal range of lowercase letters is 97 to 122, and that of uppercase letters is 65 to 90. Then when I make statistics, the condition is that they correspond to the decimal number. The lower-case letter statistical value is put into an array, and the upper-case letter statistical number is put into an array, and then unified into an array.

The size of the array is 26. This simplifies the problem. It is assumed that only English letters are allowed.

I think the written code is more intuitive and easy to understand.

<Iostream> <. h> * Str = iArrSmall [iArrBig [iSum [(I =; I <; I ++ = iArrBig [I] =; (I =; I <strlen (Str ); I ++ (Str [I]> & Str [I] <)-] ++ (Str [I] <= & Str [I]>) -] ++ <(I =; I <; ++ = iArrBig [I] + iSmallestIndex = iSum [(I =; I <; ++ (iSmallestIndex> iSum [I] & iSum [I] >=<<< (iSmallestIndex +) <(iSmallestIndex +) <iSum [iSmallestIndex] <strNew [index = (I =; I <strlen (Str ); I ++ (Str [I])! = (ISmallestIndex +) & (Str [I])! = (ISmallestIndex ++] = <strlen (strNew) <strNew <Str = <Str <View Code

 

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.