随笔分类 -  Leetcode

摘要:Dynamic ProgrammingGiven a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is f... 阅读全文
posted @ 2014-11-24 08:53 Jessica程序猿 阅读(207) 评论(0) 推荐(0)
摘要:Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-o... 阅读全文
posted @ 2014-11-23 22:27 Jessica程序猿 阅读(197) 评论(0) 推荐(0)
摘要: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-11-23 18:35 Jessica程序猿 阅读(167) 评论(0) 推荐(0)
摘要:Dynamic Programming参考:http://fisherlei.blogspot.com/2012/12/leetcode-jump-game.htmlhttp://blog.csdn.net/linhuanmars/article/details/21354751Given an a... 阅读全文
posted @ 2014-11-23 16:44 Jessica程序猿 阅读(245) 评论(0) 推荐(0)
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.C++代码实现:#include#include#include#includeu... 阅读全文
posted @ 2014-11-23 15:16 Jessica程序猿 阅读(166) 评论(0) 推荐(0)
摘要:Given a collection of integers that might contain duplicates,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.... 阅读全文
posted @ 2014-11-23 11:52 Jessica程序猿 阅读(192) 评论(1) 推荐(0)
摘要: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-11-23 11:20 Jessica程序猿 阅读(179) 评论(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 ... 阅读全文
posted @ 2014-11-23 08:56 Jessica程序猿 阅读(185) 评论(0) 推荐(0)
摘要:Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to... 阅读全文
posted @ 2014-11-22 21:21 Jessica程序猿 阅读(155) 评论(0) 推荐(0)
摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value t... 阅读全文
posted @ 2014-11-22 21:09 Jessica程序猿 阅读(170) 评论(0) 推荐(0)
摘要:Follow upfor "Find Minimum in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Suppose a sort... 阅读全文
posted @ 2014-11-22 18:55 Jessica程序猿 阅读(185) 评论(0) 推荐(0)
摘要:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest le... 阅读全文
posted @ 2014-11-22 16:08 Jessica程序猿 阅读(192) 评论(0) 推荐(0)
摘要:Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1].C+... 阅读全文
posted @ 2014-11-22 08:23 Jessica程序猿 阅读(174) 评论(0) 推荐(0)
摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.首先我是要AVL树的创建过程进行操作,不过提交之后出现超时,但还是让我将AVL树的创建过程实现了一遍,记录... 阅读全文
posted @ 2014-11-21 22:25 Jessica程序猿 阅读(235) 评论(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 @ 2014-11-21 20:25 Jessica程序猿 阅读(164) 评论(0) 推荐(0)
摘要:The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total number... 阅读全文
posted @ 2014-11-21 19:39 Jessica程序猿 阅读(170) 评论(0) 推荐(0)
摘要:Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete a... 阅读全文
posted @ 2014-11-21 18:47 Jessica程序猿 阅读(145) 评论(0) 推荐(0)
摘要:Dynamic ProgrammingSay you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most ... 阅读全文
posted @ 2014-11-21 17:39 Jessica程序猿 阅读(130) 评论(0) 推荐(0)
摘要:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le... 阅读全文
posted @ 2014-11-21 17:05 Jessica程序猿 阅读(169) 评论(0) 推荐(0)
摘要:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possibl... 阅读全文
posted @ 2014-11-21 15:33 Jessica程序猿 阅读(178) 评论(0) 推荐(0)