You are coding as a Guest. Sign in with your RoleNest account to permanently track your streak, earn XP, and climb the Campus Leaderboard!
Sign In with RoleNestProblem Set
🔥Partition Labels: Greedy Last Occurrence ChunksMedium
DAILY PROBLEM OF THE DAY+50 XP • Daily Streak
Solve today's challenge or tackle one of the 3 Super Hard challenges for +150 XP.
MediumTwo Pointers•Acceptance: 80.1%
Partition Labels: Greedy Last Occurrence Chunks
Targeted in FAANG & Tech OA:AmazonGoogle
Real-World Engineering Context
Used in microservice distributed transaction boundary chunking and video stream keyframe chunk segmentation.
You are given a string `s`. We want to partition the string into as many parts as possible so that each letter appears in at most one part.
Note that the partition is done so that after concatenating all the parts in order, the resultant string should be `s`.
Return a list of integers representing the size of these parts.
Sample Test Cases
Input: ["ababcbacadefegdehijhklij"]
Expected: [9,7,8]
Input: ["eccbbbbdec"]
Expected: [10]
Input: ["abc"]
Expected: [1,1,1]
Constraints
- 1 <= s.length <= 500
- s consists of lowercase English letters.
Recruiter Fast-Track ReferralVerified Candidate
Direct pipeline to Google, Amazon, Microsoft, Swiggy, & Uber recruiters
Top DevScore profiles bypass resume screening filters. Every verified problem solve writes authentic proof-of-work to your profile and dispatches you directly into employer inboxes on RoleNest.
Explore 5,000+ Direct ATS Openings on RoleNest ↗✓ Direct Referral Active
Language:
Ready to test. Click Run Code or Submit Solution to run test cases in isolated browser sandbox.