the solution for leetcode online judge (www.leetcode.com/onlinejudge).