![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Leetcode
文章平均质量分 73
Mavs
CSE
展开
-
Leetcode LinkedList Summary
参考文章:http://blog.csdn.net/luckyxiaoqiang/article/details/7393134Leetcode 中 链表节点定义如下:struct ListNode {int val;ListNode *next;ListNode(int x) : val(x), next(NULL) {}};原创 2014-02-27 06:40:21 · 1094 阅读 · 0 评论 -
LeetCode Matrix Summary
题目:1. Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[[ 1, 2, 3 ],[ 4, 5, 6 ],[ 7, 8,原创 2014-02-27 06:41:49 · 1286 阅读 · 0 评论 -
LeetCode Gray Code
1.Gray CodeThe gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print原创 2014-02-28 06:15:51 · 5088 阅读 · 1 评论 -
LeetCode 回溯算法 backtracking
1. Sudoku Solverrite a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique soluti原创 2014-03-07 06:41:40 · 2366 阅读 · 0 评论 -
LeetCode 问题汇总(算法,难度,频率)
IdQuestionDifficultyFrequencyData StructuresAlgorithms1Two Sum25array + setsort + two pointers2Add Two Numbers34linked listtwo point转载 2014-03-13 11:58:30 · 14132 阅读 · 0 评论 -
Leetcode 之二叉树 tree
1. Recover Binary Search TreeTwo 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原创 2014-03-04 01:34:03 · 3566 阅读 · 0 评论 -
LeetCode 之二分法查找 Binary search
1. Search for a RangeGiven a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).原创 2014-03-10 14:07:46 · 1002 阅读 · 0 评论 -
LeetCode 之排序 sorting
1. First Missing PositiveGiven 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原创 2014-03-18 04:18:09 · 1535 阅读 · 0 评论 -
LeetCode Summary of Data Structure & Algorithms
1. 常见数据结构线性:数组:Merge Sorted Array链表:Merge k Sorted Lists,Partition List队列,堆栈,块状数组(数组+链表),hash表,双端队列,位图(bitmap)树: 二叉树: Minimum Depth of Binary Tree, Path Sum II, Inorder Trave转载 2014-03-04 01:37:28 · 1835 阅读 · 0 评论 -
LeetCode 之模拟&贪心
1.Palindrome NumberDetermine 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 yo原创 2014-03-04 05:10:42 · 2090 阅读 · 0 评论 -
LeetCode 之递归问题(二)
1. Generate ParenthesisGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()()原创 2014-04-02 09:36:08 · 1689 阅读 · 0 评论 -
LeetCode 之堆栈 stack
1. Valid ParentheseGiven a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()"原创 2014-03-07 07:23:24 · 2477 阅读 · 0 评论 -
LeetCode 问题汇总之递归算法
参考文章:http://fisherlei.blogspot.com最近在刷LeetCode,开始刷题--面试--刷题。。。下面将遇到的可以用递归求解的问题归纳于此1. CombinationGiven two integers n and k, return all possible combinations of k numbers out of 1 ... n.原创 2014-02-27 04:37:35 · 12461 阅读 · 0 评论 -
LeetCode 实现题(一)
1. Valid SodokuDetermine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.原创 2014-03-06 11:42:26 · 1286 阅读 · 0 评论 -
Leetcode 之链表问题 (一)
1. Merge k sorted listsMerge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.//Merge k sorted linked lists and return it as one sorted list. Analyze原创 2014-04-02 09:59:10 · 1178 阅读 · 0 评论 -
LeetCode 之双指针 two pointers
1. 3SumGiven an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a t原创 2014-03-11 01:20:51 · 6285 阅读 · 1 评论 -
Leetcode 之图的算法
1. Clone GraphClone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # a原创 2014-04-04 05:05:10 · 2208 阅读 · 0 评论 -
LeetCode 之动态规划
1. Jump GameGiven 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 length at that positi原创 2014-03-07 12:27:36 · 9713 阅读 · 0 评论 -
LeetCode 之实现题(二)
1. Integer to RomanGiven an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.主要是按区间处理每一位digit1digit==4digit==55digit==9string in原创 2014-04-02 08:58:49 · 799 阅读 · 0 评论 -
LeetCode 之 DFS 深度优先遍历
1. Palindrome Partioning IIGiven a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s原创 2014-03-12 04:18:02 · 3159 阅读 · 0 评论 -
[LeetCode] Unique Binary Search Trees II
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1 3原创 2014-05-15 01:22:34 · 1365 阅读 · 0 评论 -
[LeetCode] Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5 / \原创 2014-05-14 06:37:01 · 4031 阅读 · 0 评论 -
[LeetCode-24]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.原创 2014-05-16 05:24:10 · 782 阅读 · 0 评论 -
[LeetCode-109] Symmetric Tree
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 / \ 2 2 / \ / \3 4 4 3But the f原创 2014-05-17 02:12:45 · 704 阅读 · 0 评论 -
[LeetCode] 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 3 3 2 1 \原创 2014-05-14 23:46:50 · 718 阅读 · 0 评论 -
[LeetCode-11] Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,3,2].Note: Recursive solutio原创 2014-05-17 01:22:30 · 685 阅读 · 0 评论 -
[LeetCode] Length of last word
Length of last wordGiven a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, ret原创 2014-05-10 00:42:05 · 655 阅读 · 0 评论 -
[LeetCode-23] Convert Sorted Array to Binary Search Tree
Because the requirement "height balanced", this problem becomes relative easy.Just recursively use the middle element in the array as the root node of the current tree(sub tree).原创 2014-05-16 05:42:17 · 671 阅读 · 0 评论 -
[LeetCode-12]Binary Tree Level Order Traversal
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20原创 2014-05-16 06:43:00 · 723 阅读 · 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 = "ADOBECODEBANC"T = "ABC"Minimum window is "BAN原创 2014-05-11 03:43:51 · 761 阅读 · 0 评论 -
[LeetCode-75]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 straight forward. Could you devis原创 2014-05-20 04:54:18 · 717 阅读 · 0 评论 -
[LeetCode] Path Sum
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 the given sum.For example:Given the below binary tree and sum原创 2014-05-14 05:32:39 · 786 阅读 · 0 评论 -
[LeetCode] 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 = "aadbbbaccc", ret原创 2014-05-12 04:19:45 · 607 阅读 · 0 评论 -
[LeetCode-12]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 less than the node's key.Th原创 2014-05-20 05:42:20 · 2254 阅读 · 0 评论 -
[LeetCode-15]Binary Tree Zigzag Level Order Traversal
Analysis:The idea is much similar to the previous question "Binary Tree Level Order Traversal", the only difference is the print order for each level. Note that we store the level order while traver原创 2014-05-20 06:04:43 · 787 阅读 · 0 评论 -
[Leetcode-48]Maximum Depth of Binary Tree
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 leaf node.原创 2014-05-21 05:00:35 · 707 阅读 · 0 评论 -
[LeetCode116]Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the原创 2014-06-03 01:01:42 · 907 阅读 · 0 评论 -
[LeetCode132]Longest Consecutive Sequence
Longest Consecutive SequenceGiven 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 consecu原创 2014-05-31 01:42:21 · 789 阅读 · 0 评论 -
[LeetCode117]Unique Paths II
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 marked as 1 and 0 respectively in the原创 2014-06-03 01:30:28 · 2144 阅读 · 0 评论 -
[LeetCode112]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 following triangle[ [2], [3,4], [原创 2014-06-04 00:17:45 · 680 阅读 · 0 评论