2014年3月4日

Sum Root to Leaf Numbers

摘要: Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which represents the number123.Find the total sum of all root-to-leaf numbers.For example, 1 / \ 2 3The root-to-leaf path1->2represents the number12.T 阅读全文

posted @ 2014-03-04 15:35 pengyu2003 阅读(122) 评论(0) 推荐(0)

Valid Palindromed

摘要: iven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama"is a palindrome."race a car"isnota palindrome.Note:Have you consider that the string might be empty? This is a good question to 阅读全文

posted @ 2014-03-04 15:20 pengyu2003 阅读(139) 评论(0) 推荐(0)

Best Time to Buy and Sell Stock

摘要: 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.vector下标,初始化class Solution {public: int maxProfit(vector... 阅读全文

posted @ 2014-03-04 14:58 pengyu2003 阅读(154) 评论(0) 推荐(0)

导航