http://www.hackerearth.com/problem/algorithm/the-best-internet-browser-3/