
leetcode不会做的
bwcxljsm
这个作者很懒,什么都没留下…
展开
-
1209. Remove All Adjacent Duplicates in String II
1209. Remove All Adjacent Duplicates in String II Given a string s, a k duplicate removal consists of choosing k adjacent and equal letters from s and removing them causing the left and the right side of the deleted substring to concatenate together. We re原创 2020-09-09 20:16:32 · 203 阅读 · 0 评论 -
667. Beautiful Arrangement II
Given two integers n and k, you need to construct a list which contains n different positive integers ranging from 1 to n and obeys the following requirement: Suppose this list is [a1, a2, a3, ... , a...原创 2018-03-28 19:22:25 · 133 阅读 · 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], therefore th...原创 2018-04-03 20:28:16 · 160 阅读 · 0 评论 -
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 of...原创 2018-04-11 09:36:23 · 202 阅读 · 0 评论 -
650. 2 Keys Keyboard
Initially on a notepad only one character 'A' is present. You can perform two operations on this notepad for each step:Copy All: You can copy all the characters present on the notepad (partial copy is...原创 2018-04-10 16:45:20 · 162 阅读 · 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 1 since t...原创 2018-03-27 21:21:54 · 118 阅读 · 0 评论 -
673. Number of Longest Increasing Subsequence
Given an unsorted array of integers, find the number of longest increasing subsequence.Example 1:Input: [1,3,5,4,7] Output: 2 Explanation: The two longest increasing subsequence are [1, 3, 4, 7] and [...原创 2018-04-02 20:02:36 · 133 阅读 · 0 评论 -
790. Domino and Tromino Tiling
We have two types of tiles: a 2x1 domino shape, and an "L" tromino shape. These shapes may be rotated.XX <- domino XX <- "L" tromino X Given N, how many ways are there to tile a 2 x N board? ...原创 2018-04-02 17:07:41 · 322 阅读 · 0 评论 -
813. Largest Sum of Averages
We partition a row of numbers A into at most K adjacent (non-empty) groups, then our score is the sum of the average of each group. What is the largest score we can achieve?Note that our partition mus...原创 2018-04-09 14:10:15 · 128 阅读 · 0 评论 -
801. Minimum Swaps To Make Sequences Increasing
We have two integer sequences A and B of the same non-zero length.We are allowed to swap elements A[i] and B[i]. Note that both elements are in the same index position in their respective sequences.A...原创 2018-03-31 21:52:08 · 151 阅读 · 0 评论 -
646. Maximum Length of Pair Chain
You are given n pairs of numbers. In every pair, the first number is always smaller than the second number.Now, we define a pair (c, d) can follow another pair (a, b) if and only if b < c. Chain of...原创 2018-04-11 20:01:19 · 149 阅读 · 0 评论 -
368. Largest Divisible Subset
Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj= 0 or Sj % Si = 0.If there are multiple solutions, return...原创 2018-03-28 19:33:06 · 125 阅读 · 0 评论 -
264. Ugly Number II
Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugl...原创 2018-03-29 11:03:58 · 118 阅读 · 0 评论 -
543Diameter of Binary Tree
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may n...原创 2019-01-19 14:50:09 · 214 阅读 · 0 评论 -
897——Increasing Order SearchTree
题目 Given a tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only 1 right child. 大意 给出一个树,重新排列,使得最左的节点是树的根...原创 2018-12-19 20:40:59 · 227 阅读 · 0 评论 -
486. Predict the Winner
Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a player picks a...原创 2018-06-09 20:54:27 · 155 阅读 · 0 评论 -
54. Spiral Matrix
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.Example 1:Input: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] Output: [1,2,3,6,9,8,7,4,5] Exampl...原创 2018-04-21 13:48:30 · 146 阅读 · 0 评论 -
416. Partition Equal Subset Sum
Given a non-empty array containing only 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 element w...原创 2018-05-08 22:28:41 · 139 阅读 · 0 评论 -
59. Spiral Matrix II
Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.Example:Input: 3 Output: [ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ] ] 题意:蛇形填数。思路:因为是从左上角顺时针开始填,所以...原创 2018-04-17 21:10:39 · 164 阅读 · 0 评论 -
740. Delete and Earn
Given an array nums of integers, you can perform operations on the array.In each operation, you pick any nums[i] and delete it to earn nums[i] points. After, you must delete every element equal to num...原创 2018-04-04 23:03:13 · 140 阅读 · 0 评论 -
263. Ugly Number
Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since it i...原创 2018-03-29 11:07:37 · 132 阅读 · 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.For example, given the following matrix:1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 Return...原创 2018-03-26 10:28:24 · 123 阅读 · 0 评论 -
712. Minimum ASCII Delete Sum for Two Strings
Given two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal.Example 1:Input: s1 = "sea", s2 = "eat" Output: 231 Explanation: Deleting "s" from "sea" adds the AS...原创 2018-04-08 10:23:52 · 135 阅读 · 0 评论 -
343. Integer Break
Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, given n = 2, return ...原创 2018-03-25 09:42:08 · 134 阅读 · 0 评论 -
565. Array Nesting
A zero-indexed array A of length N contains all integers from 0 to N-1. Find and return the longest length of set S, where S[i] = {A[i], A[A[i]], A[A[A[i]]], ... } subjected to the rule below.Suppose ...原创 2018-02-23 21:47:26 · 108 阅读 · 0 评论 -
5. 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.Example:Input: "babad" Output: "bab" Note: "aba" is also a valid answer. Example:I...转载 2018-03-09 12:08:54 · 108 阅读 · 0 评论 -
188. Best Time to Buy and Sell Stock IV
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most k transactions.Note:You may not engage i...原创 2018-03-15 16:48:19 · 126 阅读 · 0 评论 -
123. Best Time to Buy and Sell Stock III
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note:You may not engage...原创 2018-03-15 16:15:01 · 130 阅读 · 0 评论 -
229. Majority Element II
Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.题意:给出一个数组,找出出现次数大于n/3的所有数,要求空间复杂度为O(1)。思路:一、用map,key为...原创 2018-03-01 11:07:40 · 126 阅读 · 0 评论 -
611. Valid Triangle Number
【LeetCode】611.Valid Triangle Number解题报告tags: Array题目地址:https://leetcode.com/problems/valid-triangle-number/description/ 题目描述: Given an array consists of non-negative integers, your task is to count t...转载 2018-02-18 21:47:24 · 123 阅读 · 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) I...原创 2018-03-08 12:11:51 · 120 阅读 · 0 评论 -
670. Maximum Swap
Given a non-negative integer, you could swap two digits at most once to get the maximum valued number. Return the maximum valued number you could get.Example 1:Input: 2736 Output: 7236 Explanation: Sw...原创 2018-02-14 16:14:31 · 143 阅读 · 0 评论 -
414. Third Maximum Number
Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).Example 1:Input: [3, 2, 1] Out...原创 2018-02-27 11:51:52 · 124 阅读 · 0 评论 -
121. Best Time to Buy and Sell Stock
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 stock), des...原创 2018-03-10 10:39:12 · 171 阅读 · 0 评论 -
139. Word Break
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. You may assu...原创 2018-03-16 21:16:51 · 111 阅读 · 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 false.题意:给出字...原创 2018-03-14 16:35:55 · 123 阅读 · 1 评论 -
338. Counting Bits
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and return them as an array.Example:For num = 5 you sho...原创 2018-03-24 14:44:25 · 139 阅读 · 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,4], [6,5,7], ...原创 2018-03-13 21:03:36 · 117 阅读 · 0 评论 -
309. Best Time to Buy and Sell Stock with Cooldown
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one an...原创 2018-03-19 15:02:28 · 165 阅读 · 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 (can ...原创 2018-03-22 21:13:07 · 124 阅读 · 0 评论