摘要: Given a binary tree, return the inorder traversal of its nodes' values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2].Note: Recursive solution is trivial, could you do it iteratively?confused what "{1,#,2,3}" means? > read more on how binary tree is serialized on 阅读全文
posted @ 2013-12-09 22:44 七年之后 阅读(214) 评论(0) 推荐(0) 编辑
摘要: Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space to hold additional elements from B. The number of elements initialized in A and B aremandnrespectively.思考:3指针。从后往前遍历。class Solution {public: void merge(int A[], int m, int B[], ... 阅读全文
posted @ 2013-12-09 16:56 七年之后 阅读(212) 评论(0) 推荐(0) 编辑
摘要: Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as1and0respectively in the grid.For example,There is one obstacle in the middle of a 3x3 grid as illustrated below.[ [0,0,0], [0,1, 阅读全文
posted @ 2013-12-09 15:07 七年之后 阅读(149) 评论(0) 推荐(0) 编辑
摘要: Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array[−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray[4,−1,2,1]has the largest sum =6.click to show more practice.More practice:If you have figured out the O(n) solution, try 阅读全文
posted @ 2013-12-09 11:47 七年之后 阅读(157) 评论(0) 推荐(0) 编辑