## Package Matching - Google Top Interview Questions

You are given two-dimensional list of integers sales and buyers. Each element in sales contains [day, price] meaning that the package is only available for sale on that day for that price. Each element in buyers contains [payday, amount] meaning that the buyer has that amount of money to spend on payday and afterwards. Given that each buyer can buy at most one package, and each package can be sold to at most one person, return the maximum number of packages that can be bought. Cons

## Permutations to Generate Binary Search Tree - Google Top Interview Questions

You are given a list of unique integers nums. We can create a binary search tree by taking each number in order and inserting it to an initially null binary search tree. Return the number of permutations of nums from which we can generate the same binary search tree. Mod the result by 10 ** 9 + 7. You can assume that the binary search tree does no rebalancing. Constraints 0 ≤ n ≤ 1,000 where n is the length of nums Example 1 Input nums = [2, 1, 3] Output 1 Explanatio

## Race to Finish Line - Google Top Interview Questions

You are driving a car in a one-dimensional line and are currently at position = 0 with speed = 1. You can make one of two moves: Accelerate: position += speed and speed *= 2 Reverse: speed = -1 if speed > 0 otherwise speed = 1. Return the minimum number of moves it would take to reach target. Constraints 1 ≤ target ≤ 100,000 Example 1 Input target = 7 Output 3 Explanation We can accelerate 3 times to reach 7. 0 -> 1 -> 3 -> 7 Example 2 Input t

## Rank of a Matrix - Google Top Interview Questions

You are given a two-dimensional list of integers matrix. Return a new matrix A with the same dimensions such that each A[r][c] is the rank of matrix[r][c]. The ranks of any two elements a and b that are either on the same row or column are calculated by: rank(a) < rank(b) if a < b rank(a) > rank(b) if a > b rank(a) = rank(b) if a = b Ranks are greater than or equal to 1 but are as small as possible. Constraints 0 ≤ n, m ≤ 250 where n and m are the number of rows

## Shortest Bridge - Google Top Interview Questions

Given a two-dimensional list of integers matrix containing 0s and 1s, 0 represents water and 1 represents land. An island is a group of connecting 1s in 4 directions that are either surrounded by 0s or by the edges. Find the shortest bridge that connects two islands. It is guaranteed that there are two and only two islands. Constraints n, m ≤ 250 where n and m are the number of rows and columns in matrix Example 1 Input matrix = [ [0, 1], [1, 0] ] Output