Solution: 思路: http://www.cnblogs.com/grandyang/p/5294255.html Time Complexity: O(N) Space Complexity: O(N) Solution Code: