上一页 1 2 3 4 5 6 7 8 9 10 ··· 16 下一页
摘要: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and... 阅读全文
posted @ 2014-04-15 10:45 beehard 阅读(122) 评论(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 ... 阅读全文
posted @ 2014-04-15 08:37 beehard 阅读(126) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Note: Rec... 阅读全文
posted @ 2014-04-14 01:45 beehard 阅读(134) 评论(0) 推荐(0) 编辑
摘要: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or... 阅读全文
posted @ 2014-04-14 01:36 beehard 阅读(110) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the total sum of all root-to-leaf numbers. For example, 1 / \ 2 3 The root-to-leaf path 1->2 represents the 阅读全文
posted @ 2014-04-13 06:46 beehard 阅读(125) 评论(0) 推荐(0) 编辑
摘要: Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases. Notes: It is intended for this problem to be specified vaguely (ie, no given input specs). You a.. 阅读全文
posted @ 2014-04-12 09:58 beehard 阅读(143) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL. Initially, all next pointers are set to NULL. Note: Yo... 阅读全文
posted @ 2014-04-12 04:19 beehard 阅读(146) 评论(0) 推荐(0) 编辑
摘要: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle [ [2], [3,4], [6,5,7], [4,1,8,3] ] The minimum path sum from top to bottom is 11 (i.e., 2 + 3 + 5 + 1 = 11). Note: Bonus point ... 阅读全文
posted @ 2014-04-12 03:51 beehard 阅读(188) 评论(0) 推荐(0) 编辑
摘要: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1]. Note: Could you optimize your algorithm to use only O(k) extra space? Solution: from back to forth... 1 class Solution { 2 public: 3 vector getRow(int rowIndex) { 4 vector res(rowIn... 阅读全文
posted @ 2014-04-12 03:38 beehard 阅读(88) 评论(0) 推荐(0) 编辑
摘要: Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given [100, 4, 200, 1, 3, 2], The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4. Your algorithm should run in O(n) complexity. Solution: Update solution. Thi. 阅读全文
posted @ 2014-04-12 03:18 beehard 阅读(122) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 16 下一页