## Rain Catcher - Amazon Top Interview Questions

You are given a list of non-negative integers nums where each element represents the height of a hill. Suppose it will rain and all the spaces between two sides get filled up. Return the amount of rain that would be caught between the hills. Constraints n ≤ 100,000 where n is the length of nums Example 1 Input nums = [2, 5, 2, 0, 5, 8, 8] Output 8 Explanation nums[2] can catch 3 rain drops, and nums[3] can catch 5 for a total of 8. Example 2 Input nums = [2

View Solution →## Bus Fare - Amazon Top Interview Questions

You are given a list of sorted integers days , where you must take the bus for on each day. Return the lowest cost it takes to travel for all the days. There are 3 types of bus tickets. 1 day pass for 2 dollars 7 day pass for 7 dollars 30 day pass for 25 dollars Constraints n ≤ 100,000 where n is the length of days Example 1 Input days = [1, 3, 4, 5, 29] Output 9 Explanation The lowest cost can be achieved by purchasing a 7 day pass in the beginning and then a 1

View Solution →## Left Side View of a Tree - Amazon Top Interview Questions

Given a binary tree root, return the leftmost node's value on each level of the tree. Constraints n ≤ 100,000 where n is the number of nodes in root Example 1 Input root = [0, [5, null, null], [2, null, [1, null, null]]] Output [0, 5, 1]

View Solution →## Tree From Pre/Inorder Traversals - Amazon Top Interview Questions

Given a list of unique integers preorder and another list of unique integers inorder, representing the pre-order and in-order traversals of a binary tree, reconstruct the tree and return the root. Constraints n ≤ 100,000 where n is the length of preorder and inorder Example 1 Input preorder = [4, 2, 1, 0, 3] inorder = [2, 1, 0, 3, 4] Output [4, [2, null, [1, null, [0, null, [3, null, null]]]], null]

View Solution →## The Auditor - Amazon Top Interview Questions

Spreadsheets often use this alphabetical encoding for its columns: "A", "B", "C", ..., "AA", "AB", "AC", ..., "ZZ", "AAA", "AAB", "AAC", .... Given a string s representing an alphabetical column id, return its column number. For example, given "A", return 1. Given "AA", return 27. Example 1 Input s = "AA" Output 27

View Solution →