## Tree Coloring - Amazon Top Interview Questions

You are given a binary tree root where the value of each node represents its color. In the tree there are at most 2 colors. Return whether it's possible to swap the colors of the nodes any number of times so that no two adjacent nodes have the same color. Constraints n ≤ 100,000 where n is the number of nodes in root Example 1 Input root = [1, [1, null, null], [1, [0, null, [0, null, null]], [0, null, null]]] Output True Explanation We can color the root with 0, the ne

## Polyglot Contest - Amazon Top Interview Questions

You are given a two-dimensional list of strings languages, where languages[i] is a list of programming languages person i is fluent in. Consider any list of programming languages such that everyone knows at least one language in it. Return the minimum size of such list. Constraints 1 ≤ n, m ≤ 16 where n and m are the number of rows and columns in languages. 1 ≤ l ≤ 32 where l is the total number of distinct strings in languages. Example 1 Input languages = [ ["Java", "Per

## String Equivalence Relations - Amazon Top Interview Questions

You are given three lowercase alphabet strings a, b and target. Strings a and b have the same length and are defined to be equivalent: a[i] = b[i]. For example, if a = "abc" and b = "xyz", then "a" = "x", "b" = "y" and "c" = "z". Also, we can make the following kinds of inferences for characters: c = c a = b implies b = a a = b and b = c implies a = c Return the smallest lexicographically equivalent string for target. Constraints n ≤ 1,000 where n is the length of a and b m ≤ 1

## Middle Operable Deque - Amazon Top Interview Questions

Implement a data structure with the following methods: void appendLeft(int val) when appends val to the left of the deque. int popLeft() which pops the leftmost value of the deque. If it's empty, return -1. void append(int val) when appends val to the end of the deque. int pop() which pops the last value of the deque. If it's empty, return -1. void appendMiddle(int val) when appends val to the middle of the deque. int popMiddle() which pops the middle value of the deque. If it'

## Circular Queue - Amazon Top Interview Questions

Implement a circular queue with the following methods: CircularQueue(int capacity) which creates an instance of a circular queue with size capacity. Circular queues are implemented using an array which holds the enqueued values with pointers pointing to the start and end of the queue. When the queue reaches the end of the array, it will start to fill items from the start of the array if they were dequeued. boolean enqueue(int val) which adds val to the queue if it has space. If the que