Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

s =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

A partition ends when we've included the last occurrence of every character seen so far.

Approach

Precompute last index of each character. Scan with a window [start..end] where end is max last index among chars in window. When i==end, cut partition.

Code
Loading...
Complexity
Time: O(n)
Space: O(1)
Solution
Updated: 2026-02-23

Idea

A partition ends when we've included the last occurrence of every character seen so far.

Approach

Precompute last index of each character. Scan with a window [start..end] where end is max last index among chars in window. When i==end, cut partition.

Code
Loading...
Complexity
Time: O(n)
Space: O(1)