![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
llwjason5555
这个作者很懒,什么都没留下…
展开
-
trapping-rain-water
题目: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. For example, Given[0,1,0,2,1,0,1,3,2,1,2,1],原创 2017-09-13 10:30:09 · 356 阅读 · 0 评论 -
multiply-strings
题目:Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-negative.程序:class Solution {public: string mu原创 2017-09-13 13:41:07 · 138 阅读 · 0 评论 -
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 should cover the原创 2017-09-13 19:21:39 · 197 阅读 · 0 评论 -
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原创 2017-09-13 20:31:06 · 123 阅读 · 0 评论 -
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原创 2017-09-13 20:34:18 · 165 阅读 · 0 评论 -
permutations
题目:Given a collection of numbers, return all possible permutations. For example, [1,2,3]have the following permutations: [1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2], and[3,2,1].程序:class Solution {publi原创 2017-09-13 20:45:05 · 305 阅读 · 0 评论 -
permutations-ii
题目:Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2]have the following unique permutations: [1,1,2],[1,2,1], and[2,1,1].程序:c原创 2017-09-13 21:10:14 · 214 阅读 · 0 评论 -
rotate-image
题目: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?程序:class Solution {public: void rotate(vector<vector原创 2017-09-13 21:29:51 · 111 阅读 · 0 评论 -
anagrams
题目:Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case.程序:class Solution {public: vector<string> anagrams(vector<string> &strs) {原创 2017-09-13 22:05:06 · 120 阅读 · 0 评论 -
powx-n
题目:Implement pow(x, n).程序:class Solution {public: double pow(double x, int n) { //求 x^n = x^(n/2) + x^(n/2) + x^(n%2) if (n < 0) return 1.0 / power(x, -n); else return pow原创 2017-09-13 22:25:18 · 186 阅读 · 0 评论 -
n-queens
题目:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions t原创 2017-09-14 12:11:24 · 163 阅读 · 0 评论 -
n-queens-ii
题目:Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.程序:class Solution {public: int count = 0;原创 2017-09-14 12:16:22 · 140 阅读 · 0 评论 -
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 subarray[4原创 2017-09-14 13:20:13 · 149 阅读 · 0 评论 -
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 target, whe原创 2017-09-06 21:33:13 · 150 阅读 · 0 评论 -
longest-substring-without-repeating-characters
题目:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for “abcabcbb” is “abc”, which the length is 3. Fo原创 2017-09-06 22:35:03 · 200 阅读 · 0 评论 -
merge-intervals
题目:Given a collection of intervals, merge all overlapping intervals. For example, Given[1,3],[2,6],[8,10],[15,18], return[1,6],[8,10],[15,18].程序:class Solution {public: vector<Interval> merge(v原创 2017-09-15 09:26:15 · 217 阅读 · 0 评论 -
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 their start times. Exa原创 2017-09-15 09:34:59 · 145 阅读 · 0 评论 -
length-of-last-word
题目:Given 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, return 0. Note: A word is defi原创 2017-09-15 09:55:08 · 186 阅读 · 0 评论 -
spiral-matrix-ii
题目:Given an integer n, generate a square matrix filled with elements from 1 to n 2 in spiral order. For example, Given n =3, You should return the following matrix: [ [ 1, 2, 3 ], [ 8, 9, 4 ],原创 2017-09-15 10:53:28 · 131 阅读 · 0 评论 -
add-two-numbers
题目:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a li原创 2017-09-07 16:05:55 · 139 阅读 · 0 评论 -
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 = 3): “123” “132” “213” “231”原创 2017-09-15 15:00:05 · 139 阅读 · 0 评论 -
rotate-list
题目:Given a list, rotate the list to the right by k places, where k is non-negative. For example: Given1->2->3->4->5->NULLand k =2, return4->5->1->2->3->NULL.程序:class Solution {public: ListNode *原创 2017-09-15 15:12:18 · 142 阅读 · 0 评论 -
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原创 2017-09-15 15:47:15 · 113 阅读 · 0 评论 -
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 as1and0respectively in the grid. F原创 2017-09-15 16:07:09 · 136 阅读 · 0 评论 -
minimum-path-sum
题目:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. Note: You can only move either down or right at原创 2017-09-15 16:12:51 · 160 阅读 · 0 评论 -
merge-two-sorted-lists
题目:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.程序:class Solution {public: ListNode *mergeTwoLists(L原创 2017-09-15 16:22:02 · 130 阅读 · 0 评论 -
longest-palindromic-substring
题目:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.程序:class Solution {publ原创 2017-09-07 18:38:36 · 210 阅读 · 0 评论 -
zigzag-conversion
题目: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 legibility) P A H N A P L S I I原创 2017-09-07 19:01:03 · 278 阅读 · 0 评论 -
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 to ask before codin原创 2017-09-07 19:25:18 · 138 阅读 · 0 评论 -
string-to-integer-atoi
题目:题目描述 Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible in原创 2017-09-07 19:37:28 · 228 阅读 · 0 评论 -
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 thinking of converting原创 2017-09-07 20:59:15 · 142 阅读 · 0 评论 -
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. Above is a histogram where width of ea原创 2017-09-24 16:04:51 · 176 阅读 · 0 评论 -
maximal-rectangle
题目:Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing all ones and return its area.程序:class Solution {public: int maximalRectangle(vector<vector<char> > &matri原创 2017-09-24 18:28:47 · 169 阅读 · 0 评论 -
partition-list
题目: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 should preserve the original relative order of the nodes in each of原创 2017-09-24 18:53:22 · 172 阅读 · 0 评论 -
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原创 2017-09-24 19:26:40 · 176 阅读 · 0 评论 -
merge-sorted-array
题目:Given two sorted integer arrays A and B, merge B into A as one sorted array. Note: You may assume that A has enough space to hold additional elements from B. The number of elements initialized in原创 2017-09-24 19:49:41 · 158 阅读 · 0 评论 -
regular-expression-matching
转载至:http://blog.csdn.net/fzzying3/article/details/42057935题目:Implement regular expression matching with support for’.’and’*’. ‘.’ Matches any single character. ‘*’ Matches zero or more of the precedi转载 2017-09-08 09:53:47 · 166 阅读 · 0 评论 -
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原创 2017-09-08 10:30:27 · 128 阅读 · 0 评论 -
integer-to-roman
题目:Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.程序:class Solution {public: string intToRoman(int num) { string res = "";原创 2017-09-08 10:41:08 · 171 阅读 · 0 评论 -
roman-to-integer
题目:Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.程序:class Solution {public: inline int map(char c){ switch(c){ cas原创 2017-09-08 10:48:52 · 148 阅读 · 0 评论