Hardware interview practice
Partition a randomized parent array
Randomize a unique five-element parent array, choose three non-empty child sizes that sum to five, then partition the parent elements among the children.
Reviewed example
Work through one case
Input
parent=[0,1,2,3,4]; randomized child sizes=[1,2,2]Expected output
child1=[0], child2=[1,2], child3=[3,4]A monotonically increasing source index slices contiguous segments and consumes every parent element exactly once.
What to cover
Requirements
- Each child size must be between 1 and 4.
- Every parent element must appear in exactly one child.
- Create and populate child arrays in post_randomize.
