leetcode
duanjinlong、
这个作者很懒,什么都没留下…
展开
-
647. Palindromic Substrings 回文子串
Given a string, your task is to count how many palindromic substrings in this string.The substrings with different start indexes or end indexes are counted as different substrings even they consist ...原创 2020-01-07 22:29:37 · 95 阅读 · 0 评论 -
931. Minimum Falling Path Sum / 1289. Minimum Falling Path Sum II
iven asquarearray of integersA, we want theminimumsum of afalling paththroughA.A falling path starts at any element in the first row, and chooses one element from each row. The next row's c...原创 2020-01-07 11:30:32 · 174 阅读 · 0 评论 -
877. Stone Game 石头游戏 (未完成)
Alex and Lee play a game with piles of stones. There are an even number ofpilesarranged in a row, and each pile has a positive integer number of stonespiles[i].The objective of the game is to en...原创 2019-12-26 15:53:34 · 135 阅读 · 0 评论 -
516. Longest Palindromic Subsequence 最长回文子串
Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000.Example 1:Input:"bbbab"Output:4One possible longest palindromic s...原创 2019-12-24 11:25:31 · 98 阅读 · 0 评论 -
494. Target Sum 目标和
You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols+and-. For each integer, you should choose one from+and-as its new symbol.Find out how m...原创 2019-12-23 16:50:41 · 82 阅读 · 0 评论 -
1277. Count Square Submatrices with All Ones 一个矩阵中有多少个正方形子矩阵
Given am * nmatrix of ones and zeros, return how manysquaresubmatrices have all ones.Example 1:Input: matrix =[ [0,1,1,1], [1,1,1,1], [0,1,1,1]]Output: 15Explanation: There are 10...原创 2019-12-19 17:02:10 · 662 阅读 · 0 评论 -
416. Partition Equal Subset Sum 分割两个和相等的子串
Given anon-emptyarray containingonly positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.Note:Each of the array elem...原创 2019-12-19 15:52:47 · 181 阅读 · 0 评论 -
413. Arithmetic Slices 算数切片
A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmetic sequence:...原创 2019-12-18 10:22:24 · 65 阅读 · 0 评论 -
377. Combination Sum IV 累加和
Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.Example:nums = [1, 2, 3]target = 4The pos...原创 2019-12-17 16:18:41 · 85 阅读 · 0 评论 -
376. Wiggle Subsequence 起伏的子串
A sequence of numbers is called awiggle sequenceif the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either pos...原创 2019-12-16 18:46:12 · 134 阅读 · 0 评论 -
368. Largest Divisible Subset 最大可除子集
Given a set ofdistinctpositive integers, find the largest subset such that every pair (, ) of elements in this subset satisfies:% = 0 or % = 0.If there are multiple solutions, return any sub...原创 2019-12-16 17:09:44 · 373 阅读 · 0 评论 -
357. Count Numbers with Unique Digits 完全不重复的数
Given anon-negativeinteger n, count all numbers with unique digits, x, where 0 ≤ x < .Example:Input: 2Output: 91 Explanation: The answer should be the total numbers in the range of 0 ≤ x &...原创 2019-12-13 11:01:16 · 153 阅读 · 0 评论 -
343. Integer Break 拆分和后求最大积
Given a positive integern, break it into the sum ofat leasttwo positive integers and maximize the product of those integers. Return the maximum product you can get.Example 1:Input: 2Output: 1...原创 2019-12-12 16:26:28 · 88 阅读 · 0 评论 -
338. Counting Bits 二进制中1的个数
Given a non negative integer numbernum. For every numbersiin the range0 ≤ i ≤ numcalculate the number of 1's in their binary representation and return them as an array.Example 1:Input: 2Out...原创 2019-12-12 11:19:32 · 115 阅读 · 0 评论 -
322. Coin Change 硬币筹钱
You are given coins of different denominations and a total amount of moneyamount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money ...原创 2019-12-12 10:31:10 · 75 阅读 · 0 评论 -
304. Range Sum Query 2D - Immutable 二维数组指定区域的和
Given a 2D matrixmatrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1,col1) and lower right corner (row2,col2).The above rectangle (with the red borde...原创 2019-12-10 12:16:27 · 98 阅读 · 0 评论 -
300. Longest Increasing Subsequence 最长自增子序列
Given an unsorted array of integers, find the length of longest increasing subsequence.Example:Input: [10,9,2,5,3,7,101,18]Output: 4 Explanation: The longest increasing subsequence is [2,3,7,1...原创 2019-12-09 16:57:35 · 99 阅读 · 0 评论 -
279. Perfect Squares 最少数量的平方和
Given a positive integern, find the least number of perfect square numbers (for example,1, 4, 9, 16, ...) which sum ton.Example 1:Input: n = 12Output: 3 Explanation: 12 = 4 + 4 + 4.Example...原创 2019-12-09 11:41:21 · 219 阅读 · 0 评论 -
264. Ugly Number II 丑数
Write a program to find then-th ugly number.Ugly numbers arepositive numberswhose prime factors only include2, 3, 5.Example:Input: n = 10Output: 12Explanation: 1, 2, 3, 4, 5, 6, 8, 9, 1...原创 2019-12-06 11:51:19 · 103 阅读 · 0 评论 -
221. Maximal Square 最大正方形
Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.Example:Input: 1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0Output: 4题意:找出矩阵中全部由1...原创 2019-12-05 16:48:25 · 110 阅读 · 0 评论 -
198. House Robber 213. House Robber II 隔家盗窃
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent house...原创 2019-11-11 21:08:08 · 119 阅读 · 0 评论 -
139. Word Break 分词
Given anon-emptystringsand a dictionarywordDictcontaining a list ofnon-emptywords, determine ifscan be segmented into a space-separated sequence of one or more dictionary words.Note:The ...原创 2019-12-03 17:37:27 · 89 阅读 · 0 评论 -
91. Decode Ways 翻译数字
A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given anon-emptystring containing only digits, determine t...原创 2019-12-02 23:27:25 · 81 阅读 · 0 评论 -
64. Minimum Path Sum 最小和路径
Given amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note:You can only move either down or right at a...原创 2019-11-28 10:26:41 · 76 阅读 · 0 评论 -
63. Unique Paths II 到达终点的路径总数
A robot is located at the top-left corner of amxngrid (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 bo...原创 2019-11-27 11:55:01 · 146 阅读 · 0 评论 -
62. Unique Paths
A robot is located at the top-left corner of amxngrid (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 bo...原创 2019-11-26 11:41:46 · 88 阅读 · 0 评论 -
5. Longest Palindromic Substring 最长回文子串
Given a strings, find the longest palindromic substring ins. You may assume that the maximum length ofsis 1000.Example 1:Input: "babad"Output: "bab"Note: "aba" is also a valid answer.Exam...原创 2019-11-25 12:27:56 · 82 阅读 · 0 评论 -
1025. Divisor Game
Alice and Bob take turns playing a game, with Alice starting first.Initially, there is a numberNon the chalkboard. On each player's turn, that player makes amoveconsisting of:Choosinganyxw...原创 2019-11-22 11:59:55 · 92 阅读 · 0 评论 -
746. Min Cost Climbing Stairs 爬梯最小花费
On a staircase, thei-th step has some non-negative costcost[i]assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of ...原创 2019-11-15 16:12:30 · 86 阅读 · 0 评论 -
392. Is Subsequence 是否为子串
Given a stringsand a stringt, check ifsis subsequence oft.You may assume that there is only lower case English letters in bothsandt.tis potentially a very long (length ~= 500,000) string,...原创 2019-11-14 22:35:53 · 92 阅读 · 0 评论 -
303. Range Sum Query - Immutable 查询区间和
Given an integer arraynums, find the sum of the elements between indicesiandj(i≤j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) -> -1sum...原创 2019-11-11 22:58:24 · 82 阅读 · 0 评论