28. Longest substring without repeats

MediumProgramAcademy Pass20 points

Write lengthOfLongestSubstring s, the length of the longest contiguous piece of s in which no character appears twice.

Examples

  1. InputlengthOfLongestSubstring "abcabcbb"Output3
  2. InputlengthOfLongestSubstring "bbbbb"Output1
  3. InputlengthOfLongestSubstring "pwwkew"Output3

Submitting also runs 6 hidden tests.

Constraints

  • Spaces are characters too.

Running and submitting solutions, the hints and the editorial come with the Academy Pass. The daily problem is open to every account.

Solution.lean
Loading editor…

Run checks your code against the examples and your custom inputs and records nothing. Submit also runs the hidden tests, confirms the axioms your proof uses and records the result. Each uses one compiler check.

ReadyLn 1, Col 1Lean 4
Draft saved in this browser