CoolMind


If you cannot measure it, you cannot improve it.

Sliding maximum of range k subarray

Problem Solution Complexity analysis Problem This problem was asked by Google. Given an array of integers and a number k...

Longest file path size

Problem Solution Problem This problem was asked by Google. Suppose we represent our file system by a string in the following manner: The ...

Fixed size queue

Problem Solution Problem This problem was asked by Twitter. You run an e-commerce website and want to record the last N order ids in a log...

Pick a number randomly from an unlimited stream

Problem Solution Comments Problem This problem was asked by Facebook. Given a stream of elements too large to store in memory, pick a ra...

Estimate PI

Problem Solution Problem This problem was asked by Google. The area of a circle is defined as $\pi r^{2}$ . Estimate $\pi$ to 3 decimal pl...

At most distinct K

Problem Solution Problem This problem was asked by Amazon. Given an integer k and a string s, find the length of the longest substring tha...

Climb up staircase

Problem Solution Reference Problem This problem was asked by Amazon. There exists a staircase with N steps, and you can climb up either ...

An autocomplete system

Problem Solution Comments Problem This problem was asked by Twitter. Implement an autocomplete system. That is, given a query string s a...