Huawei testing (B)

Source: Internet
Author: User
Input:  

A string contains only lowercase English letters. invalid input is not considered. The length of the input string is less than or equal to 20 bytes.

 
Output:  

Delete the character string that contains the least number of characters.

 
Sample input:
abcdd                   
Sample output:
dd

 

# Include <iostream> # include <string> # include <iomanip> # include <vector> using namespace STD; int main () {string input; Getline (CIN, input ); unsigned Len = input. size (); If (LEN = 0) {cout <Endl; return 0;} vector <int> VES (26, 0 ); // number of times characters stored in VES appear int min = Len; // minimum number of times of occurrence unsigned I, j; for (I = 0; I <Len; I ++) {ves [input [I]-'a'] ++;} for (I = 0; I <Len; I ++) {If (VES [input [I]-'a'] <min) min = ves [input [I]-'a'];} For (j = 0; j <Len; j ++) {If (VES [input [J]-'a']! = Min) cout <input [J];} cout <Endl; return 0 ;}

 

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.