Convert Sorted List to Binary Search Tree

摘要: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.分析:将一个按升序排列的单链表转换成一个平衡二叉查找树,难点在于如何确定单链表的中... 阅读全文
posted @ 2014-08-14 15:27 Ryan-Xing 阅读(142) 评论(0) 推荐(0) 编辑

Jump Game

摘要: Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximu... 阅读全文
posted @ 2014-08-13 13:41 Ryan-Xing 阅读(387) 评论(0) 推荐(0) 编辑

Path Sum II

摘要: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree andsum =... 阅读全文
posted @ 2014-08-13 13:30 Ryan-Xing 阅读(117) 评论(0) 推荐(0) 编辑

Count and Say

摘要: The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off as"tw... 阅读全文
posted @ 2014-08-13 12:54 Ryan-Xing 阅读(422) 评论(0) 推荐(0) 编辑

Search for a Range

摘要: Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the ord... 阅读全文
posted @ 2014-08-12 14:59 Ryan-Xing 阅读(177) 评论(0) 推荐(0) 编辑

Unique Paths II

摘要: 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 i... 阅读全文
posted @ 2014-08-12 14:30 Ryan-Xing 阅读(104) 评论(0) 推荐(0) 编辑

Subsets

摘要: Given a set of distinct integers,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not co... 阅读全文
posted @ 2014-08-12 00:44 Ryan-Xing 阅读(190) 评论(0) 推荐(0) 编辑

Valid Sudoku

摘要: 这道题是个细节实现题,只要把valid sudoku满足的三个条件判断一下即可。valid sudoku需满足下列三个条件:1)每一行数字1~9有且只出现一次。2)每一列数字1~9有且只出现一次。3)对于每个3*3的sub-box(用i=3、6,j=3、6两条线划分,总共9个sub-box)数字1~... 阅读全文
posted @ 2014-08-10 21:16 Ryan-Xing 阅读(163) 评论(0) 推荐(0) 编辑

Longest Consecutive Sequence

摘要: 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 ... 阅读全文
posted @ 2014-08-10 14:31 Ryan-Xing 阅读(134) 评论(0) 推荐(0) 编辑

Valid Parentheses

摘要: Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct ... 阅读全文
posted @ 2014-08-10 13:36 Ryan-Xing 阅读(81) 评论(0) 推荐(0) 编辑