http://leetcode.com/onlinejudge solution