Categories
interview

K Empty Slots – Java

Time O(nlogn)
Space O(n)

Categories
interview

Top K Frequent Elements – Java

Runtime O(nlogn)

Categories
interview

Reverse Words in a String – Java

Using a Stack
Uses O(n) memory and time.

Categories
interview

Generate Paranthesis – Java

 

Categories
interview

Sort Array by Parity – Java

This solution runs in 0(n) time (linear) and uses O(1) space (constant) and is based on the Dutch National Flag Problem.