摘要: Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit.#simple way.class Solution {public: int maxProfit(vecto... 阅读全文
posted @ 2012-12-20 16:16 西施豆腐渣 阅读(177) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 / \ 2 3 Return6.key-points: globe variable record the max value of local branch.at the end, in root node compare max value cross root node w... 阅读全文
posted @ 2012-12-20 15:38 西施豆腐渣 阅读(155) 评论(0) 推荐(0) 编辑