摘要: Algorithm: Scan through the array, keep finding 1. prices[i] with the condition: prices[i] prices[i+1], or at the end of an ascending trend, trea... 阅读全文
posted @ 2014-12-31 01:25 jiangyuan916 阅读(205) 评论(0) 推荐(0)
摘要: preOrder: (root) LLL RRRRinOrder: LLL (root) RRRRinOrder: LLL RRRR (root)根据preOrder/postOrder 可以知道root(一头一尾); 然后找到root在inorder中对应的位置(index)index左边即为Le... 阅读全文
posted @ 2014-12-30 13:18 jiangyuan916 阅读(139) 评论(0) 推荐(0)
摘要: Two pointer, 一头一尾;brute force的话需要时间复杂度为O(n^2);但是two pointer的方法可以进行简化(通过对某些case的省略): 具体: height[low] = height[high]: 则知道 height[high]与任意height[low... 阅读全文
posted @ 2014-12-30 08:18 jiangyuan916 阅读(127) 评论(0) 推荐(0)