title-img


Split List to Minimize Largest Sum - Amazon Top Interview Questions

Given a list of non-negative integers nums and an integer k, you can split the list into k non-empty sublists. Return the minimum largest sum of the k sublists. Constraints k ≤ n ≤ 100,000 where n is the length of nums Example 1 Input nums = [1, 3, 2, 4, 9] k = 2 Output 10 Explanation We can split the list into these 2 sublists: [1, 3, 2, 4] and [9].

View Solution →

Stack of Stacks - Amazon Top Interview Questions

Implement a data structure with the following methods: StackOfStacks(int capacity) which instantiates an instance that represents an infinite number of stacks, each with size capacity. void push(int val) which pushes the value val to the leftmost stack that's not full. int pop() which pops the value of the top element of the rightmost non-empty stack. If every stack is empty, return -1. int popStack(int idx) which pops the value of the top element of the idx (0-indexed) stack.

View Solution →

String Expansion - Amazon Top Interview Questions

You are given a string s consisting of lowercase alphabet characters, digits, and brackets"(" and ")". s encodes a longer string and is represented as concatenation of n(t), where n is the number of times t is repeated, and t is either a regular string or it's another encoded string recursively. Return the expanded version of s. Note that t can be the empty string. Example 1 Input s = "2(ye)0(z)2(2(po)w)" Output "yeyepopowpopow"

View Solution →

The Meeting Place Sequel - Amazon Top Interview Questions

You are given a two dimensional integer matrix consisting of: 0 which represents an empty cell. 1 which represents a wall. 2 which represents a person. A person can walk up, down, left, right or stay in one time unit. Find a walkable cell such that it minimizes the time it would take for everyone to meet and return the time. Note: two people can walk through the same empty cell and you can assume there is always some path between any two people. Constraints The number of cells in

View Solution →

Wildfire Sequel- Amazon Top Interview Questions

You are given a two-dimensional integer matrix matrix where 0 represents empty cell 1 represents a person 2 represents fire 3 represents a wall You can assume there's only one person and in each turn fire expands in all four directions although fire can't expand through walls. Return whether the person can move to either the top left corner or the bottom right corner. In each turn, the person moves first, then the fire expands. If the person makes it to either square as the same time a

View Solution →