## Roomba - Amazon Top Interview Questions

A Roomba robot is currently sitting in a Cartesian plane at (0, 0). You are given a list of its moves that it will make, containing NORTH, SOUTH, WEST, and EAST. Return whether after its moves it will end up in the coordinate (x, y). Constraints n ≤ 100,000 where n is length of moves Example 1 Input moves = ["NORTH", "EAST"] x = 1 y = 1 Output True Explanation Moving north moves it to (0, 1) and moving east moves it to (1, 1) Example 2 Input moves = [

View Solution →## First Fit Room - Amazon Top Interview Questions

You are given a list of integers rooms and an integer target. Return the first integer in rooms that's target or larger. If there is no solution, return -1. Constraints 0 ≤ n ≤ 100,000 where n is the length of rooms Example 1 Input rooms = [15, 10, 30, 50, 25] target = 20 Output 30 Explanation 30 is the first room that's at least as large as 20. Example 2 Input rooms = [15, 10, 30, 50, 25] target = 51 Output -1 Explanation There's no room that'

View Solution →## Wolves of Wall Street - Amazon Top Interview Questions

Given a list of integers prices representing the stock prices of a company in chronological order, return the maximum profit you could have made from buying and selling that stock any number of times. You must buy before you can sell it. But you are not required to buy or sell the stock. Constraints 0 ≤ n ≤ 100,000 where n is the length of prices Example 1 Input prices = [1, 5, 3, 4, 6] Output 7 Explanation We can buy at 1, sell at 5, buy at 3, and sell at 6.

View Solution →## Unique Fractions - Amazon Top Interview Questions

You are given a list of lists fractions where each list contains [numerator, denominator] which represents the number numerator / denominator. Return a new list of lists such that the numbers in fractions are: In their most reduced terms. E.g. 8 / 6 becomes 4 / 3. Any duplicate fractions that represent the same value are removed. Sorted in ascending order by their value. If the number is negative, the - sign should go to the numerator (the input also follows this). Constraints n ≤

View Solution →## Largest Sum After K Negations - Amazon Top Interview Questions

You are given a list of integers nums and an integer k. Consider an operation where you pick an element in nums and negate it. Given that you must make exactly k operations, return the maximum resulting sum that can be obtained. Constraints n ≤ 100,000 where n is the length of nums k < 2 ** 31 Example 1 Input nums = [1, 0, -5, -3] k = 4 Output 9 Explanation We can negate -5 and -3 once each and 0 twice to get [1, 0, 5, 3] and its sum is 9.

View Solution →