Round 1 : LIVE CODING
Problem: Dinner Plate Stacks
Problem Description
API or Method Signatures
public void push(int val) //Pushes a plate with value val onto the leftmost pile with space.
public int pop() //Pops and returns the plate from the rightmost non-empty pile.
public int popAtStack(int index) //Pops and returns the plate from the pile index.
Constraints
Example Input/Output
DinnerPlateStacks stacks = new DinnerPlateStacks(2);
stacks.push(1);
stacks.push(2);
stacks.push(3);
stacks.push(4);
stacks.push(5);
// The stacks are now: 2 4
// 1 3 5
// ﹈ ﹈ ﹈
stacks.popAtStack(0); // Output: 2
// The stacks are now: 4
// 1 3 5
// ﹈ ﹈ ﹈
stacks.push(20);
// The stacks are now: 20 4
// 1 3 5
// ﹈ ﹈ ﹈
stacks.push(21);
// The stacks are now: 20 4 21
// 1 3 5
// ﹈ ﹈ ﹈
stacks.popAtStack(0); // Output: 20
// The stacks are now: 4 21
// 1 3 5
// ﹈ ﹈ ﹈
stacks.popAtStack(2); // Output: 21
// The stacks are now: 4
// 1 3 5
// ﹈ ﹈ ﹈
stacks.pop(); // Output: 5
// The stacks are now: 4
// 1 3
// ﹈ ﹈ ﹈
stacks.pop(); // Output: 4
// The stacks are now:
// 1 3
// ﹈ ﹈ ﹈
PS : goal is give a working solution with test cases