Glovo || software engineer 2 || barcelona
- Location
- barcelona
- Posted
- 28 Nov 2025
Summary
I participated in a live coding round for a Software Engineer 2 role at Glovo in Barcelona, where I was tasked with solving a complex data structure design problem involving dinner plate stacks.
How it went
I had a live coding round for the Software Engineer 2 position at Glovo in Barcelona. The problem presented was 'Dinner Plate Stacks', which required me to design and implement a data structure to manage stacks of plates with specific push, pop, and popAtStack operations. The round focused on providing a working solution with test cases, and I concentrated on the logic and implementation details for each method, considering the constraints and edge cases.
Questions asked (1)
- 01
Dinner Plate Stacks
Data Structures & Algorithms
Problem Description
- Design and implement a data structure to simulate stacks of dinner plates arranged in piles.
- Each pile can hold a fixed number of plates (capacity).
- When pushing a plate, it should go onto the leftmost pile that is not full.
- When popping a plate, it should come from the rightmost non-empty pile.
- You can also pop a plate from a specific pile by index.
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
- Capacity is a positive integer.
- Index in popAtStack may refer to a non-existent or empty pile.
- If no plates are available to pop, return -1.
- There is no limit on the number of plates
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