摘要: Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->NULL.先算出链表... 阅读全文
posted @ 2014-06-23 20:56 OpenSoucre 阅读(124) 评论(0) 推荐(0) 编辑
摘要: Implement strStr().Returns a pointer to the first occurrence of needle in haystack, ornullif needle is not part of haystack.class Solution {public: ... 阅读全文
posted @ 2014-06-23 20:20 OpenSoucre 阅读(140) 评论(0) 推荐(0) 编辑
摘要: Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given"25525511135",return["255.2... 阅读全文
posted @ 2014-06-23 18:14 OpenSoucre 阅读(127) 评论(0) 推荐(0) 编辑
摘要: Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.No... 阅读全文
posted @ 2014-06-23 17:16 OpenSoucre 阅读(134) 评论(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 (size that is greater or equal... 阅读全文
posted @ 2014-06-23 17:02 OpenSoucre 阅读(107) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.TreeNode *createSearchTree(ListNode *&hea... 阅读全文
posted @ 2014-06-23 16:06 OpenSoucre 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST.TreeNode *createSearchTree(vector& num, int left , in... 阅读全文
posted @ 2014-06-23 15:26 OpenSoucre 阅读(142) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only n... 阅读全文
posted @ 2014-06-23 14:48 OpenSoucre 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For exa... 阅读全文
posted @ 2014-06-23 14:11 OpenSoucre 阅读(123) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and al... 阅读全文
posted @ 2014-06-23 14:06 OpenSoucre 阅读(146) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2... 阅读全文
posted @ 2014-06-23 13:55 OpenSoucre 阅读(156) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ ... 阅读全文
posted @ 2014-06-23 12:25 OpenSoucre 阅读(137) 评论(0) 推荐(0) 编辑
摘要: Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical an... 阅读全文
posted @ 2014-06-23 12:19 OpenSoucre 阅读(101) 评论(0) 推荐(0) 编辑
摘要: A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point ... 阅读全文
posted @ 2014-06-23 12:03 OpenSoucre 阅读(124) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe... 阅读全文
posted @ 2014-06-23 00:22 OpenSoucre 阅读(166) 评论(0) 推荐(0) 编辑