Redistribute Megaseeds
Problem Overview
- Compute the minimum operations to redistribute Megaseeds so each crate’s count is divisible by an integer div > 1; return -1 if impossible.
- Input: num crates (0..num-1) with nonnegative counts, at least one non-empty; Output: minimum operations or -1.
- One operation moves a single seed from crate i to the preceding crate or to any later crate.
- Context: Rick and Morty-themed resource redistribution under a modular constraint.
- From Rubrik interviews; a coding interview problem and interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
