Tìm xâu liên tiếp dài nhất chứa các ký tự không lặp lại
Given a string, find the length of the longest substring without repeating characters.
Input: "abcabcbb"
Output: 3
Explanation: The answer is "abc", with the length of 3.
Input: "bbbbb"
Output: 1
Explanation: The answer is "b", with the length of 1.
Input: "pwwkew" Output: 3 Explanation: The answer isLàm bài này tôi dùng cấu trúc dữ liệu Hashset, tôi sẽ dùng 3 biến start (lưu vị trí bắt đầu của xâu dài nhất), end chạy trên xâu, max để lưu kết quả."wke", with the length of 3. Note that the answer must be a substring,"pwke"is a subsequence and not a substring.
Xin cảm ơn.
Nhận xét
Đăng nhận xét