摘要: Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct ... 阅读全文
posted @ 2015-09-09 21:05 irun 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu... 阅读全文
posted @ 2015-09-09 20:50 irun 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo... 阅读全文
posted @ 2015-09-09 20:04 irun 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 百度:1.从键盘输入一个字符串,长度未知,然后输出所有的全排列。例如输入abc, 输出abc,acb,bac,bca,cab,cba这样。很遗憾,当时思路不清晰,说了半天没说出个所以然。不知道这种题目对于大家来说是不是很简单,一下就做出来了。2.生日悖论问题。不知道自己去百度吧。这个问题其实很简单的... 阅读全文
posted @ 2015-08-29 21:55 irun 阅读(185) 评论(0) 推荐(0) 编辑
摘要: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.Solution 1: recursionruntime: 28ms./** * ... 阅读全文
posted @ 2015-08-25 23:42 irun 阅读(164) 评论(0) 推荐(0) 编辑
摘要: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-... 阅读全文
posted @ 2015-08-23 22:58 irun 阅读(169) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?Hide Tags:Linked ListTwo PointersHide Simi... 阅读全文
posted @ 2015-08-18 16:23 irun 阅读(84) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, return the node where the cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it without using extra space?Sol... 阅读全文
posted @ 2015-08-18 16:22 irun 阅读(177) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth... 阅读全文
posted @ 2015-08-18 15:07 irun 阅读(132) 评论(0) 推荐(0) 编辑
摘要: Given a non-negative integernum, repeatedly add all its digits until the result has only one digit.For example:Givennum = 38, the process is like:3 + ... 阅读全文
posted @ 2015-08-16 23:56 irun 阅读(322) 评论(0) 推荐(0) 编辑