Five rounds each of 45 minutes. All coding questions, no behavioral.
You are given an deck of cards, each labelled anywhere from 1 to 52.
A straight is defined as a set of five cards with consecutive labels, eg: 4, 5, 6, 7, 8
Given n cards, write a function that returns true if those cards can be arranged to contain all straights
func ("2, 5, 6, 7, 10, 3, 4, 8, 9, 1") returns true.
func ("2, 5, 6, 7, 10, 3, 4, 8, 9") returns false.
The cards can be labelled as any integer.
You are given a vector of operations. Each operation is of three parts: { [a-z], [<>], [a-z] }
[a-z] => single lowercase alphabet.
[<>] => 'greater than', or 'less than' operation.
Write a function that returns true if the operations are valid.
func ({{"a", ">", "b"}, {"b", ">", "c"}}) return true
func ({{"a", ">", "b"}, {"b", ">", "a"}}) return false
The input could also have integers, eg. ({{"a", ">", "1"}, {"b", ">", "2"}})
Given the root node of a binary tree and a node in the binary tree, delete that node from the binary tree and return the modifed root node.
I worte a recursive solution. Interviewer asked me to write an iterative solution.
We have a system with these properties:
Given a string, write a function that returns true, if for some N, that string can be outputted by a run of this system.
func({0, 3, 2, 1}) returns true. A set of valid operation with N = 3 is:
func({0, 3, 1, 2}) returns false. To print "0, 3", steps #1 to #5 from the previous section will needed. After that there is no way to print 1 without printing 2. (since print happens on pop and 1 is after 2 in the stack)
I wrote an O(n) time, O(n) space solution.
Interviewer asked for an O(1) space solution.
Round 4:
Round 5: