Leetcode3 longest substring whitout repeat characters

Source: Internet
Author: User

Evaluate the length of the longest non-duplicate substring in the string, for example, "abcabcbb". The longest non-duplicate substring is "ABC" and the length is 3. Because there are no duplicates required, we want to use hashmap to store them, because the key values of hashmap cannot be repeated. The character to be saved is used as the key, and the subscript of the character in the string is used as the value. If the map already contains this character, the character and all the characters before this character are deleted, and then store the data. For example, if the string is "abcbd", if ABC has been saved, and B is saved now, AB is deleted and saved to (B, 3). Max is the value that contains the maximum number of characters in map.


Leetcode3 longest substring whitout repeat characters

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.