随笔分类 -  Leetcode

上一页 1 2 3 4 5 6 7 下一页

Class
摘要:1. No const constructorUnlike other member functions, constructors may not be declared as const . When we create a const object of a class type, the o... 阅读全文

posted @ 2014-10-14 16:14 Ryan-Xing 阅读(243) 评论(0) 推荐(0)

Substring with Concatenation of All Words
摘要:You are given a string,S, and a list of words,L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenati... 阅读全文

posted @ 2014-10-06 11:43 Ryan-Xing 阅读(212) 评论(0) 推荐(0)

Leetcode: Minimum window substring
摘要:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S="ADOBECODEBA... 阅读全文

posted @ 2014-10-04 16:56 Ryan-Xing 阅读(184) 评论(0) 推荐(0)

Word Ladder
摘要:Given two words (startandend), and a dictionary, find the length of shortest transformation sequence fromstarttoend, such that:Only one letter can be ... 阅读全文

posted @ 2014-10-03 23:48 Ryan-Xing 阅读(285) 评论(0) 推荐(0)

Insertion Sort List
摘要:Sort a linked list using insertion sort.分析:插入排序的过程是从第二个元素开始,将该元素插入到前面已拍好序的序列的正确位置。如果数据结构是单链表,则主要考察单链表的结点移动操作。将一个结点插入到另一个结点的前面,需要这两个结点的previous结点。特别要注意... 阅读全文

posted @ 2014-08-20 16:19 Ryan-Xing 阅读(149) 评论(0) 推荐(0)

Next Permutation
摘要:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possibl... 阅读全文

posted @ 2014-08-19 00:14 Ryan-Xing 阅读(143) 评论(0) 推荐(0)

Palindrome Partitioning
摘要:Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ofs.For example, giv... 阅读全文

posted @ 2014-08-18 13:50 Ryan-Xing 阅读(126) 评论(0) 推荐(0)

Add Binary
摘要:Given two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".分析:该题需要注意的地方:1)两个string的长度可能不同 2)近位借鉴leetcode-c... 阅读全文

posted @ 2014-08-18 13:20 Ryan-Xing 阅读(167) 评论(0) 推荐(0)

Validate Binary Search Tree
摘要: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-08-18 12:03 Ryan-Xing 阅读(128) 评论(0) 推荐(0)

Leetcode: Letter Combinations of a Phone Number
摘要:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephon... 阅读全文

posted @ 2014-08-17 15:44 Ryan-Xing 阅读(156) 评论(0) 推荐(0)

Construct Binary Tree from Inorder and Postorder Traversal
摘要:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree. 1 class Solut... 阅读全文

posted @ 2014-08-17 00:12 Ryan-Xing 阅读(138) 评论(0) 推荐(0)

Construct Binary Tree from Preorder and Inorder Traversal
摘要:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.分析:通过一个二叉树的先序遍历... 阅读全文

posted @ 2014-08-16 23:28 Ryan-Xing 阅读(165) 评论(0) 推荐(0)

Combination Sum
摘要:Given a set of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Thesamerepeated num... 阅读全文

posted @ 2014-08-16 16:33 Ryan-Xing 阅读(117) 评论(0) 推荐(0)

Partition List
摘要: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-08-16 15:58 Ryan-Xing 阅读(200) 评论(0) 推荐(0)

Binary Tree Zigzag Level Order Traversal
摘要: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-08-16 00:15 Ryan-Xing 阅读(118) 评论(0) 推荐(0)

Triangle
摘要:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the fol... 阅读全文

posted @ 2014-08-15 23:26 Ryan-Xing 阅读(229) 评论(0) 推荐(0)

Subsets II
摘要: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-08-15 20:39 Ryan-Xing 阅读(370) 评论(0) 推荐(0)

3Sum Closest
摘要:Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You m... 阅读全文

posted @ 2014-08-15 19:26 Ryan-Xing 阅读(140) 评论(0) 推荐(0)

Unique Binary Search Tree II
摘要:Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 uni... 阅读全文

posted @ 2014-08-14 17:00 Ryan-Xing 阅读(195) 评论(0) 推荐(0)

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 阅读(149) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 下一页