摘要: 099 Recover Binary Search Tree没有按照要求用 constant space.... 用valid BST 找出两个not in order 的nodesclass Solution: def recoverTree(self, root): [fN,... 阅读全文
posted @ 2015-08-06 05:25 dapanshe 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 105 Construct Binary Tree from Preorder and Inorder Traversal这道题纯递归class Solution: # @param {integer[]} preorder # @param {integer[]} inorder ... 阅读全文
posted @ 2015-08-06 01:45 dapanshe 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 214 Shortest Palindrome这道题会用到一个算法在 这里用过利用这个算法稍作改进即可class Solution: def shortestPalindrome(self, s): T = '#'.join('${}&'.format(s)) an... 阅读全文
posted @ 2015-08-06 00:34 dapanshe 阅读(92) 评论(0) 推荐(0) 编辑