Find the first occurrence of a string in a string, such as input "Abaccdeff", Output ' B '

Source: Internet
Author: User

Find the first occurrence of a string in a string, such as input "Abaccdeff", output ' B '

1 CharFirstnotrepeatingchar (Char*str)2 {3     /*The hash table stores the number of occurrences of each possible character as an array of indexed values*/4     CharRET =' /';5     //1. Establish Hashtable6     Const intSize = the;7     //all initialized to 08     intHashtable[size] = {0};9     Char*hashkey =str;Ten     //2. Record Occurrences One      while(*hashkey! =' /') A     { -hashtable[*hashkey]++; -hashkey++; the     } -     //3. Find the return -HashKey =str; -      while(*hashkey! =' /') +     { -         if(Hashtable[*hashkey] = =1) +         { ARET = *HashKey; at             returnret; -         } -hashkey++; -     } -     returnret; -  in}

Find the first occurrence of a string in a string, such as input "Abaccdeff", Output ' B '

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.