- 博客(21)
- 收藏
- 关注
原创 3. Longest Substring Without Repeating Characters
3. Longest Substring Without Repeating Characters Given a string, find the length of the longest substring without repeating characters. Example 1: Input: “abcabcbb” Output: 3 Expla...
2018-08-20 15:24:13 106
原创 区间类问题整理
对于区间类的问题,整体思路都是在某个维度进行排序之后,用贪心算法在每一步做出最优的选择。435. Non-overlapping Intervals 给定一串区间,求最少删除多少个可以使不重复; Input: [ [1,2], [2,3], [3,4], [1,3] ] Output: 1 Explanation: [1,3] can be removed a...
2018-08-20 15:21:08 289
原创 410. Split Array Largest Sum
410. Split Array Largest Sum Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize ...
2018-08-09 11:11:55 152
原创 368. Largest Divisible Subset
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. ...
2018-08-07 16:43:49 110
原创 44. Wildcard Matching
Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for ‘?’ and ‘*’. ‘?’ Matches any single character. ‘*’ Matches any sequence of characters (includ...
2018-08-06 17:10:06 130
原创 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: A = [1, 2, 3, 4] re...
2018-08-06 11:08:36 75
原创 97. Interleaving String
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. Input: s1 = “aabcc”, s2 = “dbbca”, s3 = “aadbbcbcac” Output: true两字符串构成第三个的基本都是从dp的角度考虑,分析时发现给定s1,s2已经使用的长度,我们...
2018-08-05 22:54:36 89
原创 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, ...
2018-08-05 20:02:11 87
原创 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. Input: n = 10 Output: 12 Explanation: 1, 2, 3, 4, 5, 6, 8, 9, ...
2018-08-05 17:48:30 140
原创 95. Unique Binary Search Trees II
Given an integer n, generate all structurally unique BST’s (binary search trees) that store values 1 … n. Example: Input: 3 Output: [ [1,null,3,2], [3,2,null,1], [3,1,nul...
2018-08-05 16:46:28 98
原创 91. Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping: ‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26 Given a non-empty string containing only digits,...
2018-08-05 16:24:29 103
原创 224. Basic Calculator
Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and emp...
2018-08-05 16:18:32 163
原创 括号系列问题总结
括号系列问题总结括号系列问题总结32. Longest Valid Parentheses22. Generate Parentheses22. Generate Parentheses32. Longest Valid Parentheses Given a string containing just the characters ‘(’ and ‘)...
2018-08-04 23:11:43 221
原创 62. Unique Paths
62. Unique Paths62. 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 r...
2018-08-03 16:48:21 86
原创 279. Perfect Squares 338. Counting Bits
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n. Input: n = 12 Output: 3 Explanation: 12 = 4 + 4 + 4.两个思考方向: 1...
2018-08-03 15:53:51 90
原创 96. Unique Binary Search Trees
DP中需要用到子问题外信息的情况分析DP中需要用到子问题外信息的情况分析问题描述问题描述 Given n, how many structurally unique BST’s (binary search trees) that store values 1 … n? Input: 3 Output: 5 Explanation: ...
2018-08-03 15:30:14 77
原创 72. Edit Distance
Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permitted on a word: Insert a character Delet...
2018-08-03 11:43:24 164
原创 DP中需要用到子问题外信息的情况分析
DP中需要用到子问题外信息的情况分析DP中需要用到子问题外信息的情况分析问题描述546. Remove Boxes312.Burst Balloon问题描述 In this case, I shall call that the definition of the subproblem is not self-contained and its solut...
2018-08-02 15:47:25 89
原创 股票系列问题总结
股票系列问题目录股票系列问题目录121.只允许卖一次122.可以卖无数次123.至多卖两次124.至多卖K次121.只允许卖一次122.可以卖无数次123.至多卖两次124.至多卖k次121.只允许卖一次 Say you have an array for which the ith element is the price o...
2018-07-31 11:57:44 609
原创 363. Max Sum of Rectangle No Larger Than K ,由之引申出的三个问题
363. Max Sum of Rectangle No Larger Than K ,由之引申出的三个问题目录363. Max Sum of Rectangle No Larger Than K ,由之引申出的三个问题目录最大连续子数组和<=k最大子数组和2d到1d的转化本Markdown编辑器使用[StackEdit][6]修改而来,用它写博...
2018-07-30 17:29:23 195
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人