a solution from discussion
Merge branch 'master' of https://github.com/mengjiaowang/leetcode