Katkat

Randomly partition array into k segments

RobloxSoftware Engineer · Technical Screen

Last updated

This question evaluates algorithm design, randomization techniques, and time/space complexity analysis within the Coding & Algorithms domain, focusing on partitioning an array into random non-empty segments.

Question

Given a list of integers and an integer k representing the number of segments, write a function that randomly partitions the list into k non-empty segments and returns them as a list of lists. Explain your approach, discuss its time and space complexity, and describe how you would test the randomness of your solution.