随笔分类 -  Leetcode

上一页 1 ··· 3 4 5 6 7 8 9 下一页
摘要:Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should ret... 阅读全文
posted @ 2014-11-19 13:30 Jessica程序猿 阅读(168) 评论(0) 推荐(0)
摘要:Dynamic ProgrammingFind the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the ... 阅读全文
posted @ 2014-11-19 09:47 Jessica程序猿 阅读(177) 评论(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 @ 2014-11-18 23:15 Jessica程序猿 阅读(200) 评论(0) 推荐(0)
摘要:Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor... 阅读全文
posted @ 2014-11-18 21:28 Jessica程序猿 阅读(175) 评论(0) 推荐(0)
摘要:Determine if a Sudoku is valid, according to:Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with ... 阅读全文
posted @ 2014-11-18 21:06 Jessica程序猿 阅读(230) 评论(0) 推荐(0)
摘要:Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi... 阅读全文
posted @ 2014-11-18 19:19 Jessica程序猿 阅读(166) 评论(0) 推荐(0)
摘要:Given an array of integers, every element appearsthreetimes except for one. Find that single one.Note:Your algorithm should have a linear runtime comp... 阅读全文
posted @ 2014-11-18 17:16 Jessica程序猿 阅读(168) 评论(0) 推荐(0)
摘要:Given an array of integers, every element appearstwiceexcept for one. Find that single one.Note:Your algorithm should have a linear runtime complexity... 阅读全文
posted @ 2014-11-18 17:05 Jessica程序猿 阅读(206) 评论(0) 推荐(0)
摘要:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo... 阅读全文
posted @ 2014-11-18 15:36 Jessica程序猿 阅读(175) 评论(0) 推荐(0)
摘要:Sort a linked list inO(nlogn) time using constant space complexity.C++代码的实现:#include#includeusing namespace std;//Definition for singly-linked list.st... 阅读全文
posted @ 2014-11-18 13:18 Jessica程序猿 阅读(212) 评论(0) 推荐(0)
摘要:Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which rep... 阅读全文
posted @ 2014-11-18 11:07 Jessica程序猿 阅读(174) 评论(0) 推荐(0)
摘要: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-11-18 10:18 Jessica程序猿 阅读(212) 评论(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-11-17 23:11 Jessica程序猿 阅读(214) 评论(0) 推荐(0)
摘要:Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1... 阅读全文
posted @ 2014-11-17 13:26 Jessica程序猿 阅读(142) 评论(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-11-17 10:10 Jessica程序猿 阅读(158) 评论(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-11-17 08:51 Jessica程序猿 阅读(230) 评论(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 @ 2014-11-16 20:32 Jessica程序猿 阅读(219) 评论(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-11-16 17:18 Jessica程序猿 阅读(233) 评论(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?本来不... 阅读全文
posted @ 2014-11-16 16:00 Jessica程序猿 阅读(218) 评论(0) 推荐(0)
摘要:Given a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For exam... 阅读全文
posted @ 2014-11-16 14:04 Jessica程序猿 阅读(164) 评论(0) 推荐(0)

上一页 1 ··· 3 4 5 6 7 8 9 下一页