Expand Compressed Bulk SKU Codes Like 2[AB3[C]]
Last updated: November 29, 2026
Quick Overview
Warehouse bulk manifests encode repeated SKU fragments as k[fragment], possibly nested. Given an encoded string, return the fully expanded string.
Flipkart
November 29, 20260
0
0 solved
Warehouse bulk manifests encode repeated SKU fragments as k[fragment], possibly nested. Given an encoded string, return the fully expanded string.
Used in Flipkart phone screens to test string parsing with nested structure, phrased around compact manifests sent between warehouse systems. The interviewer checks stack based parsing, multi digit counts, and clean handling of nesting.
What the Interviewer Expects
- Handle multi digit repeat counts
- Use a stack of (previous string, count) frames for nesting
- Build strings with lists to avoid quadratic concatenation
- Explain behavior on plain text without brackets
- Discuss output size versus input size
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you validate malformed input like unbalanced brackets?
- What if the expanded output could be gigabytes, and you only need the character at index i?
- How would you write the inverse (compress a string)?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Grammar: text is letters, or
k[text]wherekis a positive integer, nested arbitrarily. - Output: the expanded string.
- Assume valid input for the core solution; validation is a follow up....
High-Level Design
Scan left to right, keeping the fragment being built (parts) and the number being read (num). On [, push the current fragment and count onto a stack and start fresh. On ], pop the frame, repea...