
leetcode-java
codefreestyle
这个作者很懒,什么都没留下…
展开
-
LeetCode 264. Ugly Number II
题目链接英文链接中文链接题目描述编写一个程序,找出第 n 个丑数。丑数就是质因数只包含 2, 3, 5 的正整数。示例:输入: n = 10输出: 12解释: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 是前 10 个丑数。说明: 1 是丑数。n 不超过1690。解题思路所有的丑数可以分为三个列表,列表如下:1 * 2, 2 * 2, 3 * 2, 4 * 2, 5 * 2, ...1 * 3, 2 * 3, 3 * 3, 4 * 3, 5 * 3,原创 2020-07-15 21:10:08 · 102 阅读 · 0 评论 -
算法——滑动窗口总结
套路一个左指针,一个右指针。其中左指针用于缩小范围,右指针用于扩大搜索范围。一般求滑动窗口的最小值都是在缩小左指针的时候取得的。右指针扩展的条件时:只要当前还没有满足条件,就暴力增长,直到第一次满足条件为止。左指针收缩的条件:只要当前指针的缩小还没影响窗口的可满足性,就一直暴力向左增长。一但当前指针向前移动的时候影响了窗口的可满足性,就记录下当前的窗口大小,并更新目前为止满足条件的最小窗口...原创 2019-04-07 17:04:18 · 2622 阅读 · 1 评论 -
974. Subarray Sums Divisible by K
题目链接974. Subarray Sums Divisible by K题目描述Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by K. Example 1:Input: A = [4,5,0,-2,-...原创 2019-01-13 19:22:59 · 458 阅读 · 0 评论 -
347. Top K Frequent Elements
题目连接347. Top K Frequent Elements题目描述Given a non-empty array of integers, return the k most frequent elements.Example 1:Input: nums = [1,1,1,2,2,3], k = 2Output: [1,2]Example 2:Input: nums = ...原创 2018-11-14 14:44:25 · 223 阅读 · 0 评论 -
416. Partition Equal Subset Sum
题目链接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...原创 2018-11-12 19:25:10 · 255 阅读 · 0 评论 -
940. Distinct Subsequences II
题目链接940. Distinct Subsequences II题目描述Given a string S, count the number of distinct, non-empty subsequences of S .Since the result may be large, return the answer modulo 10^9 + 7.Example 1:Inpu...原创 2018-11-11 14:57:29 · 319 阅读 · 0 评论 -
939. Minimum Area Rectangle
题目链接939. Minimum Area Rectangle题目描述Given a set of points in the xy-plane, determine the minimum area of a rectangle formed from these points, with sides parallel to the x and y axes.If there isn’t...原创 2018-11-11 13:53:42 · 863 阅读 · 2 评论 -
115. Distinct Subsequences
题目链接 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 ori...原创 2018-11-09 22:05:23 · 308 阅读 · 0 评论 -
224. Basic Calculator
题目链接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-nega...原创 2018-10-11 21:03:20 · 145 阅读 · 0 评论 -
84. Largest Rectangle in Histogram
题目链接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...原创 2018-10-10 12:25:22 · 125 阅读 · 0 评论 -
96. Unique Binary Search Trees
题目链接Unique Binary Search Trees题目描述Given n, how many structurally unique BST’s (binary search trees) that store values 1 … n?Example:Input: 3Output: 5Explanation:Given n = 3, there are a total ...原创 2018-10-09 18:44:44 · 144 阅读 · 0 评论 -
187. Repeated DNA Sequences
题目链接187. Repeated DNA Sequences题目描述All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identif...原创 2018-09-11 12:11:56 · 116 阅读 · 0 评论 -
899. Orderly Queue
原题链接899. Orderly Queue题目描述A string S of lowercase letters is given. Then, we may make any number of moves.In each move, we choose one of the first K letters (starting from the left), remove...原创 2018-09-02 16:59:40 · 407 阅读 · 0 评论 -
898. Bitwise ORs of Subarrays
题目链接898. Bitwise ORs of Subarrays题目描述We have an array A of non-negative integers.For every (contiguous) subarray B = [A[i], A[i+1], …, A[j]] (with i <= j), we take the bitwise OR of all t...原创 2018-09-02 16:37:55 · 483 阅读 · 0 评论 -
897. Increasing Order Search Tree
原题链接897 Increasing Order Search Tree题目描述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 onl...原创 2018-09-02 16:15:19 · 494 阅读 · 2 评论 -
37. Sudoku Solver
题目链接https://leetcode.com/problems/sudoku-solver/description/题目描述Write a program to solve a Sudoku puzzle by filling the empty cells.A sudoku solution must satisfy all of the following rules:...原创 2018-08-29 11:17:12 · 189 阅读 · 0 评论 -
36. Valid Sudoku
题目链接https://leetcode.com/problems/valid-sudoku/discuss/题目描述Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:Each row must...原创 2018-08-29 09:18:32 · 132 阅读 · 0 评论 -
22. Generate Parentheses
题目链接:https://leetcode.com/problems/generate-parentheses/description/描述Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, gi...原创 2018-08-27 20:48:36 · 220 阅读 · 0 评论 -
47. Permutations II
原题链接https://leetcode.com/problems/permutations-ii/description/描述Given a collection of numbers that might contain duplicates, return all possible unique permutations.Example:Input: [1,1...原创 2018-08-26 20:54:07 · 174 阅读 · 0 评论 -
46. Permutations
原题链接https://leetcode.com/problems/permutations/description/题目描述Given a collection of distinct integers, return all possible permutations.ExampleInput: [1,2,3]Output:[ [1,2,3], [1...原创 2018-08-26 17:45:14 · 273 阅读 · 0 评论 -
90. Subsets II
题目链接https://leetcode.com/problems/subsets-ii/description/题目描述Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set).Note: The solutio...原创 2018-08-24 15:49:22 · 160 阅读 · 0 评论 -
78. Subsets
题目链接: https://leetcode.com/problems/subsets/description/ 题目描述:Given a set of distinct integers, nums, return all possible subsets (the power set).Note: The solution set must not contain duplica...原创 2018-08-24 10:27:14 · 564 阅读 · 0 评论 -
77. Combinations
题目:https://leetcode.com/problems/combinations/description/ 描述: Given two integers n and k, return all possible combinations of k numbers out of 1 … n.Example:Input: n = 4, k = 2Output:[ [2,4...原创 2018-08-24 10:18:26 · 265 阅读 · 0 评论 -
leeCode题目324. Wiggle Sort II
Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]….Example: (1) Given nums = [1, 5, 1, 1, 6, 4], one possible answer is [1, 4, 1, 5, 1, 6]. (2) Given nums = [1原创 2017-12-13 17:45:48 · 299 阅读 · 0 评论