自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(46)
  • 收藏
  • 关注

原创 Distinct Subsequences

Distinct Subsequences Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a new string which is formed from the original string by

2014-09-19 20:02:50 401

原创 Scramble String

Scramble String Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representation of s1 = "great": gre

2014-09-19 19:22:05 498

原创 Populating Next Right Pointers in Each Node

Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its next right node. If the

2014-09-18 11:28:00 366

原创 Longest Consecutive Sequence

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 consecuti

2014-09-18 11:21:42 359

原创 Maximum Subarray

Maximum Subarray Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2,1,−3,4,−1,2,1,−5,4], the contiguous su

2014-09-18 11:11:21 380

原创 Gas Station

Gas Station There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from

2014-09-18 10:37:37 706

原创 Palindrome Number

Palindrome Number Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: Could negative integers be palindromes? (ie, -1) If you are th

2014-09-18 10:29:43 366

原创 Reverse Integer

Reverse Integer Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Have you thought about this? Here are some good questions

2014-09-18 10:17:41 371

原创 Letter Combinations of a Phone Number

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 telephone but

2014-09-17 08:57:37 439

原创 Swap Nodes in Pairs

Swap Nodes in Pairs Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use o

2014-09-17 08:49:38 359

原创 LastNode of 完全二叉树

题目:求完全二叉树中,最后

2014-09-12 11:15:54 572

原创 Evaluate Reverse Polish Notation

Evaluate Reverse Polish Notation Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression

2014-09-11 14:48:48 319

原创 Reverse Words in a String

Reverse Words in a String Total Accepted: 31611 Total Submissions: 224230 Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue is sk

2014-09-11 14:38:38 359

原创 Word Break

Word Break Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words. For example, given s = "leetcode",

2014-09-11 11:09:18 524

原创 Combinations

Combinations Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example, If n = 4 and k = 2, a solution is: [ [2,4], [3,4], [2,3], [1,2],

2014-09-11 11:00:46 357

原创 Remove Element

Remove Element Given an array and a value, remove all instances of that value in place and return the new length. The order of elements can be changed. It doesn't matter what you leave beyond th

2014-09-11 10:56:02 380

原创 Copy List with Random Pointer

Copy List with Random Pointer A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy of the list.

2014-09-11 10:45:10 334

原创 Rotate List

Rotate List Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL.

2014-09-11 10:34:23 326

原创 各种List Sort

排序算法,

2014-09-11 09:50:45 395

原创 Add Binary

Add Binary Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100".

2014-09-09 15:09:06 389

原创 Anagrams

Anagrams Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case. 题目:理解anagrams的意思,

2014-09-09 14:40:30 481

原创 Sqrt(x)

Sqrt(x) Implement int sqrt(int x). Compute and return the square root of x. 题目:求平凡

2014-09-08 09:55:24 1538

原创 Word Ladder

Word Ladder Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: Only one letter can be changed at a timeEach i

2014-09-08 09:30:37 460

原创 Valid Palindrome

Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Panama" is a palindrome. "r

2014-09-07 16:58:06 281

原创 Set Matrix Zeroes

Set Matrix Zeroes Total Accepted: 16376 Total Submissions: 53084 Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.

2014-09-07 16:41:22 462

原创 Climbing Stairs

Climbing Stairs You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? 题目:爬楼梯,每次

2014-09-07 16:34:59 324

原创 Pow(x, n)

Pow(x, n) Implement pow(x, n). 题目:实现求幂函数。 分析:

2014-09-06 20:43:37 612

原创 Implement strStr()

Implement strStr() Total Accepted: 18315 Total Submissions: 83921 Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack

2014-09-06 20:28:52 301

原创 Sum Root to Leaf Numbers

Sum Root to Leaf Numbers Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the nu

2014-09-04 22:38:19 297

原创 各种Parentheses

Valid Parentheses Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the correct order, "()" and "

2014-09-04 22:11:05 379

原创 2sum 3sum 4sum 各种sum

Two Sum 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 numbers such that they add up to the

2014-09-02 21:04:41 530

原创 Flatten Binary Tree to Linked List

Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1 \

2014-08-31 19:41:13 304

原创 Unique Binary Search Trees I & II

Unique Binary Search Trees Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example, Given n = 3, there are a total of 5 unique BST's. 1

2014-08-28 17:02:22 339

原创 Recover Binary Search Tree

Recover Binary Search Tree Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Note: A solution using O(n) space is pretty strai

2014-08-28 16:34:24 300

原创 Convert Sorted Array(List) to Binary Search Tree

Convert Sorted Array to Binary Search Tree Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 题意:用一个有序数组

2014-08-28 16:27:40 482

原创 Validate Binary Search Tree

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 nodes with k

2014-08-28 09:42:22 317

原创 Binary Tree Maximum Path Sum

Binary Tree Maximum Path Sum  My Submissions Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. For example: Given the below binary tree,

2014-08-26 21:37:18 445

原创 Remove Duplicates from Sorted List I II

Remove Duplicates from Sorted List  My Submissions Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 

2014-08-25 20:08:23 413

原创 Reverse Linked List II

Reverse Linked List II   Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL.

2014-08-25 19:47:30 499

原创 Permutation Sequence

Permutation Sequence   The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, We get the following sequence (ie, for n =

2014-08-23 19:42:25 405

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除