![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Leetcode
GNIHTON
这个作者很懒,什么都没留下…
展开
-
241. Different Ways to Add Parentheses
题目:Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are+, - and *.Example 1: Inpu原创 2017-09-24 09:30:03 · 196 阅读 · 0 评论 -
115. Distinct Subsequences
题目:Given a string S and a string T, count the number of distinct subsequences of S which equals T.A subsequence of a string is a new string which is formed from the original string by deleting some (ca原创 2018-01-04 19:33:32 · 125 阅读 · 0 评论 -
120. 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,原创 2018-01-04 20:18:27 · 119 阅读 · 0 评论 -
72. Edit Distance
题目:Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:a)原创 2017-12-29 15:36:07 · 116 阅读 · 0 评论 -
120. Triangle
题目:Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = “aab”, Return原创 2018-01-04 23:39:21 · 144 阅读 · 0 评论 -
132. Palindrome Partitioning II
题目:Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = “aab”, Return原创 2018-01-04 23:40:02 · 126 阅读 · 0 评论 -
10. Regular Expression Matching
题目:Implement regular expression matching with support for ‘.’ and ‘*’. ‘.’ Matches any single character. ‘*’ Matches zero or more of the preceding element. The matching should cover the en原创 2017-10-08 10:45:54 · 151 阅读 · 0 评论 -
55. Jump Game
题目: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 length at that position.Determine if原创 2018-01-06 15:39:55 · 187 阅读 · 0 评论 -
45. Jump Game II
题目: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 length at that position.Your goal is原创 2018-01-06 16:52:15 · 115 阅读 · 0 评论 -
32. Longest Valid Parentheses
题目:Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.For “(()”, the longest valid parentheses substring is “()”, whi原创 2017-12-27 21:48:00 · 164 阅读 · 0 评论 -
134. 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 station i to i原创 2018-01-06 20:35:58 · 226 阅读 · 0 评论 -
135. Candy
题目:There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least on原创 2018-01-06 21:43:40 · 168 阅读 · 0 评论 -
98. 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 thanthe node’s key. T原创 2018-01-07 22:11:20 · 147 阅读 · 0 评论 -
99. 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 devise原创 2018-01-07 22:50:14 · 129 阅读 · 0 评论 -
124. Binary Tree Maximum Path Sum
题目:Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The原创 2018-01-08 15:54:24 · 131 阅读 · 0 评论 -
129. 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 number 123.Find the total s原创 2018-01-08 16:37:07 · 139 阅读 · 0 评论 -
leetcode 题目列表
# Title Type Difficulty 2 Add Two Numbers List Medium 4 Median of Two Sorted Arrays Binary Search Hard 10 Regular Expression Matching Dynamic Programming Hard原创 2017-09-10 19:43:26 · 404 阅读 · 0 评论 -
215. Kth Largest Element in an Array
题目:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For example, Given [3,2,1,5,6,4] and k = 2, return 5.原创 2018-01-13 11:32:22 · 159 阅读 · 0 评论 -
300. Longest Increasing Subsequence
题目:Given an unsorted array of integers, find the length of longest increasing subsequence.For example, Given [10, 9, 2, 5, 3, 7, 101, 18], The longest increasing subsequence is [2, 3, 7, 101], theref原创 2017-12-28 16:26:16 · 132 阅读 · 0 评论 -
315. Count of Smaller Numbers After Self
题目:You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].Example 1:原创 2017-09-24 11:12:14 · 186 阅读 · 0 评论 -
4. Median of Two Sorted Arrays
题目:There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1: nums1 = [1, 3原创 2017-09-16 20:35:40 · 271 阅读 · 0 评论 -
23. Merge k Sorted Lists
23. Merge k Sorted ListsMerge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.解法一:刚学习了分而治之的方法,正好这道题目可以采用这种方法来做,原创 2017-09-10 19:51:23 · 184 阅读 · 0 评论 -
240. Search a 2D Matrix II
题目:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Integers in each原创 2017-09-10 22:43:59 · 163 阅读 · 0 评论 -
493. Reverse Pairs
题目:Given an array nums, we call (i, j) an important reverse pair if i < j and nums[i] > 2*nums[j]. You need to return the number of important reverse pairs in the given array.Example 1: Input: [1,3,原创 2017-10-01 10:51:50 · 159 阅读 · 0 评论 -
2. Add Two Numbers
题目:You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return原创 2017-10-15 22:36:55 · 150 阅读 · 0 评论 -
19. Remove Nth Node From End of List
题目:Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the l原创 2017-10-15 23:24:15 · 153 阅读 · 0 评论 -
24. 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 only constant space. You may原创 2017-10-15 23:55:25 · 139 阅读 · 0 评论 -
84. Largest Rectangle in Histogram
题目:Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.For example,given heights =[2,1,5,6,2,3],r原创 2018-01-01 11:00:01 · 148 阅读 · 0 评论 -
85. Maximal Rectangle
题目:Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s and return its area.For example, given the following matrix: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1原创 2018-01-01 12:37:11 · 121 阅读 · 0 评论 -
87. 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”: great / \ gr原创 2018-01-02 16:14:28 · 119 阅读 · 0 评论 -
91. Decode Ways
题目:A message containing letters from A-Z is being encoded to numbers using the following mapping: ‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26Given an encoded message containing digits, determine the tota原创 2018-01-02 17:33:06 · 117 阅读 · 0 评论 -
63. 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 grid.Fo原创 2017-12-27 14:10:23 · 127 阅读 · 0 评论 -
62. 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 b原创 2017-12-27 13:29:59 · 119 阅读 · 0 评论 -
97. 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”, return fa原创 2018-01-03 17:05:12 · 143 阅读 · 0 评论 -
44. Wildcard Matching
题目: Implement wildcard pattern matching with support for ‘?’ and ‘*’. ‘?’ Matches any single character. ‘*’ Matches any sequence of characters (including the empty sequence). The matching sho原创 2017-12-28 15:18:36 · 119 阅读 · 0 评论 -
127. Word Ladder
题目:Given two words (beginWord and endWord), and a dictionary’s word list, find the length of shortest transformation sequence from beginWord to endWord, such that:Only one letter can be changed at原创 2018-01-09 18:35:41 · 167 阅读 · 0 评论