
Algorithm
文章平均质量分 64
iteye_8091
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[LeetCode] 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 keys ...2013-04-28 22:50:27 · 124 阅读 · 0 评论 -
[Leetcode] Binary Tree Level Order Traversal
Binary Tree Level Order TraversalSep 29 '125832 / 14746 Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given b...2013-09-10 14:39:15 · 103 阅读 · 0 评论 -
[Leetcode] Convert Sorted List to Binary Search Tree
Convert Sorted List to Binary Search TreeOct 3 '125768 / 16298 Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. /** * Defi...2013-09-11 16:06:34 · 99 阅读 · 0 评论 -
[Leetcode] Decode Ways
Decode WaysJun 25 '126747 / 26583 A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given an encoded ...2013-09-11 17:33:06 · 76 阅读 · 0 评论 -
[Leetcode] Word Search
Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or v...2013-09-21 23:21:41 · 91 阅读 · 0 评论 -
[Leetcode] Partition List
Partition List AC Rate: 428/1694 My Submissions Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You s...原创 2013-09-29 23:38:02 · 103 阅读 · 0 评论 -
[Leetcode] Scramble String
Scramble String AC Rate: 318/1523 My Submissions Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one p...2013-10-03 16:55:11 · 91 阅读 · 0 评论 -
[Leetcode] Remove Duplicates from Sorted List 1 & 2
Remove Duplicates from Sorted List AC Rate: 984/2755 My Submissions Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1-...2013-10-03 23:34:35 · 125 阅读 · 0 评论 -
[Leetcode] Path Sum
Path Sum AC Rate: 872/2770 My Submissions 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 t...原创 2013-10-03 23:52:53 · 119 阅读 · 0 评论 -
[Leetcode] Subsets 1 ^& 2
SubsetsApr 18 '126226 / 16269 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 contain...2013-09-09 21:42:58 · 79 阅读 · 0 评论 -
[Leetcode] Unique Paths II
Unique Paths IIMar 29 '124573 / 11497 Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty space is ...2013-09-09 21:10:42 · 94 阅读 · 0 评论 -
[Leetcode] Multiply Strings
Multiply StringsMar 12 '124253 / 16074 Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-negativ...2013-08-20 18:48:44 · 98 阅读 · 0 评论 -
[Leetcode] Wildcard Matching
Wildcard MatchingMar 16 '127489 / 29783 Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any sequence of characters (including the...2013-08-22 10:07:47 · 97 阅读 · 0 评论 -
[Leetcode] Jump Game / Jump Game II
Jump GameMar 25 '126923 / 16241 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 maximum jump len...2013-08-22 10:31:25 · 101 阅读 · 0 评论 -
[Leetcode] Permutations / Permutations II
Permutations IIMar 17 '124943 / 12877 Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example,[1,1,2] have the following unique permuta...2013-08-22 15:41:54 · 107 阅读 · 0 评论 -
[Leetcode] Rotate Image
Rotate ImageMar 18 '124182 / 9471 You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up:Could you do this in-place? 这题我第一次做时候,实现的非...2013-08-22 15:54:25 · 87 阅读 · 0 评论 -
[Leetcode] Balanced Binary Tree
Balanced Binary TreeOct 9 '127722 / 18479 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...2013-08-27 20:53:01 · 112 阅读 · 0 评论 -
[Leetcode] Triangle
TriangleOct 30 '126503 / 17796 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 following tria...2013-09-04 16:32:45 · 100 阅读 · 0 评论 -
[Leetcode] Flatten Binary Tree to Linked List
Flatten Binary Tree to Linked ListOct 14 '127105 / 21371 Given a binary tree, flatten it to a linked list in-place. For example,Given 1 / \ 2 5 / \ \ ...2013-09-09 02:35:44 · 100 阅读 · 0 评论 -
[Leetcode] Copy List with Random Pointer
Copy List with Random Pointer AC Rate: 350/1573 My Submissions A linked list is given such that each node contains an additional random pointer which could point to any node in the ...2013-10-05 22:43:13 · 104 阅读 · 0 评论 -
[Leetcode] Single Number 1 & 2
Single Number AC Rate: 1243/2713 My Submissions Given an array of integers, every element appears twice except for one. Find that single one. Note:Your algorithm should have a ...2013-10-05 22:50:54 · 138 阅读 · 0 评论 -
[LeetCode] Interleaving String
Interleaving String Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example,Given:s1 = "aabcc",s2 = "dbbca", When s3 = "aadbbcbcac", return true.When s3 = "a...2013-01-03 18:26:32 · 72 阅读 · 0 评论 -
[LeetCode] ZigZag Conversion
ZigZag ConversionDec 6 '11 The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legib...2013-03-01 23:52:25 · 98 阅读 · 0 评论 -
[LeetCode] 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 time Each i...2013-03-05 00:43:56 · 92 阅读 · 0 评论 -
[LeetCode] Longest Consecutive Sequence
Longest Consecutive SequenceFeb 14 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 conse...2013-03-05 14:51:06 · 109 阅读 · 0 评论 -
[LeetCode] Surrounded Regions
Surrounded RegionsFeb 22 Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded region . For ex...2013-03-05 17:36:14 · 87 阅读 · 0 评论 -
[LeetCode] Triangle
TriangleOct 30 '12 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 following triangle [ ...2013-03-13 23:36:16 · 86 阅读 · 0 评论 -
[LeetCode] Populating Next Right Pointers in Each Node II
Populating Next Right Pointers in Each Node IIOct 28 '12423 / 1042 Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would yo...2013-04-09 14:56:02 · 95 阅读 · 0 评论 -
[LeetCode] Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. /** * Definition for singly-linked list. * struct ListNode { * int val; * Lis...2013-04-23 00:01:50 · 75 阅读 · 0 评论 -
[LeetCode] Insert Interval
Insert Interval Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to the...2012-12-16 23:54:05 · 84 阅读 · 0 评论 -
[LeetCode] Implement strStr()
Implement strStr() Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack. 方法:KMP 正好趁这个题目温习了一下KMP字符串匹配。母串S, 模式串P KMP算法...2012-12-15 14:17:17 · 126 阅读 · 0 评论 -
[Leetcode] Word Break 1 & 2
Word Break AC Rate: 2/13 My Submissions 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 w...2013-10-05 23:26:18 · 175 阅读 · 0 评论 -
[Leetcode] Gas Station
Gas Station AC Rate: 1017/4717 My Submissions 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 ...2013-10-07 00:02:52 · 214 阅读 · 0 评论 -
[LeetCode]Best Time to Buy and Sell Stock 1 2 3
1. Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the ...原创 2012-11-15 22:14:28 · 97 阅读 · 0 评论 -
[LeetCode]Binary Tree Traversal & Binary Tree Maximum Path Sum
本文LeetCode(http://www.leetcode.com/onlinejudge)内的binary tree travel,包含3个: 1). Binary Tree Inorder Traversal 2). Binary Tree Level Order Traversal 3). Binary Tree Maximum Path Sum 1). Binary Tr...原创 2012-11-16 22:33:51 · 131 阅读 · 0 评论 -
[LeetCode]Container With Most Water
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find t...原创 2012-11-26 20:26:09 · 81 阅读 · 0 评论 -
[LeetCode]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 deleting some (can be no...2012-12-11 22:37:06 · 89 阅读 · 0 评论 -
[LeetCode]Divide Two Integers
Divide Two Integers Divide two integers without using multiplication, division and mod operator. 不用*, /, %来实现除法。 注意:1.正负号;2.INT_min=-2147483648,变为正数越界。 const int INTMIN = -2147483648; c...2012-12-13 00:20:08 · 76 阅读 · 0 评论 -
[LeetCode]First Missing Positive
First Missing Positive Given an unsorted integer array, find the first missing positive integer. For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2. Your algorithm should run in O(n) t...2012-12-13 01:16:29 · 85 阅读 · 0 评论 -
[Leetcode] Trapping Rain Water
Trapping Rain WaterMar 10 '124164 / 10550 Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. ...2013-08-20 13:10:57 · 77 阅读 · 0 评论