Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training

33. Longest Substring Without Repeating Characters

MediumDay 11 of 60Sliding Window

Given a string s, return the length of the longest substring (a contiguous block of characters) in which no character appears more than once.

Example 1
Input: s = "abcabcbb"
Output: 3
The substring "abc" has length 3; any longer block repeats a letter.
Example 2
Input: s = "pwwkew"
Output: 3
"wke" works. Note "pwke" is a subsequence, not a substring.
Constraints
  • 0 <= s.length <= 5 * 10^4
  • `s` may contain letters, digits, symbols and spaces
Hints
Frequently asked at: Amazon, Microsoft, Google, Meta, Adobe, Bloomberg
Ctrl + Enter runs the examples

Not sure what to learn next?

A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

  1. 1Discuss your goals
  2. 2Get a personal plan
  3. 3Start learning
Book for β‚Ή200/ 30 min