## Inorder Successor - Amazon Top Interview Questions

Given a binary search tree root containing unique values, and an integer t, return the value of the inorder successor of t. That is, return the smallest value greater than t in the tree. Note: you can assume that the inorder successor exists. Bonus: solve it in \mathcal{O}(h)O(h) time and \mathcal{O}(1)O(1) space where h is the height of the tree. Constraints n ≤ 100,000 where n is the number of nodes in root Example 1 Input root = [2, [0, null, [1, null, null]], [3, null, [

## Conway's Game of Life - Amazon Top Interview Questions

You are given a two dimensional matrix where a 1 represents a live cell and a 0 represents a dead cell. A cell's (living or dead) neighbors are its immediate horizontal, vertical and diagonal cells. Compute the next state of the matrix using these rules: Any living cell with two or three living neighbors lives. Any dead cell with three living neighbors becomes a live cell. All other cells die. Constraints n, m ≤ 500 where n and m are the number of rows and columns in matrix Example

## Cut Palindrome - Amazon Top Interview Questions

Given two strings a and b of equal length, return whether it is possible to cut both strings at a common point such that the first part of a and the second part of b form a palindrome. Constraints n ≤ 100,000 where n is the length of a and b Example 1 Input a = "cat" b = "pac" Output True Explanation If we cut the strings into "c" + "at" and "p" + "ac", then "c" + "ac" is a palindrome. Example 2 Input a = "iceboat" b = "racecar" Output True Explanat

## Binary Tree Nodes Around Radius - Amazon Top Interview Questions

You are given a binary tree root containing unique integers and integers target and radius. Return a sorted list of values of all nodes that are distance radius away from the node with value target. Constraints 1 ≤ n ≤ 100,000 where n is number of nodes in root 0 ≤ distance ≤ 100,000 Example 1 Input root = [3, [5, null, null], [2, [1, [6, null, null], [9, null, null]], [4, null, null]]] target = 4 radius = 2 Output [1, 3] Example 2 Input root = [0, null, null] t