- 博客(74)
- 收藏
- 关注
原创 九章算法 强化 Lecture 5 DP上滚动数组 划分型 博弈型 区间型
滚动数组110确定状态研究最优策略的最后一步转化为子问题转移方程根据子问题定义直接得到初始条件和边界情况仔细,考虑周全计算顺序利用之前的计算结果划分型动态规划512676博弈动态规划395区间型动态规划求一段区间的最大最小值168...
2020-03-02 05:16:43 179
原创 九章算法 强化 Lecture 4 扫描线二分法双端队列
扫描线例题 LintCode 391. Number of Airplanes in the SkyGiven an list interval, which are taking off and landing time of the flight. How many airplanes are there at most at the same time in the sky?Examp...
2020-03-02 02:28:52 380
原创 Java 数据类型转换 以及 Arrays Collections
array 和 ArrayList 转换array -> ArrayList把 array 中的每个元素加到 ArrayList 中 List staffsList = new ArrayList<String>(); for(String temp: staffs) { staffsList.add(temp); }ArrayList -> array...
2020-01-13 12:31:46 137
原创 LeetCode BinarySearch 69. Sqrt(x)
69. Sqrt(x)Implement int sqrt(int x).Compute and return the square root of x, where x is guaranteed to be a non-negative integer.Since the return type is an integer, the decimal digits are truncate...
2019-12-24 09:55:20 95
原创 LeetCode BinarySearch 852. Peak Index in a Mountain Array 1095. Find in Mountain Array
852. Peak Index in a Mountain ArrayLet’s call an array A a mountain if the following properties hold:A.length >= 3There exists some 0 < i < A.length - 1 such thatA[0]<A[1]<...A[i−1...
2019-12-24 06:18:46 97
原创 LeetCode BinarySearch 162. Find Peak Element
162. Find Peak ElementA peak element is an element that is greater than its neighbors.Given an input array nums, where nums[i] ≠ nums[i+1], find a peak element and return its index.The array may co...
2019-12-24 05:38:42 95
原创 LeetCode BinarySearch 240. Search a 2D Matrix II
240. Search a 2D Matrix IIWrite an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left t...
2019-12-24 05:21:05 92
原创 LeetCode BinarySearch 74 Search a 2D Matrix
74. Search a 2D MatrixWrite an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The firs...
2019-12-24 00:52:08 68
原创 Leetcode BinarySearch 302 Smallest Rectangle Enclosing Black Pixels
302. Smallest Rectangle Enclosing Black PixelsAn image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black pixels are connected, i.e., there is only one black ...
2019-12-23 13:12:58 141
原创 LeetCode BinarySearch 33 & 81 Search in Rotated Sorted Array I II
33. Search in Rotated Sorted ArraySuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).You are given a ...
2019-12-23 13:10:56 100
原创 Leetcode BinarySearch 153 154 Find Minimum in Rotated Sorted Array l & ll
153. Find Minimum in Rotated Sorted ArraySuppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).Find th...
2019-12-22 09:14:01 58
原创 LeetCode BinarySearch 702 Search in a Sorted Array of Unknown Size
702. Search in a Sorted Array of Unknown SizeGiven an integer array sorted in ascending order, write a function to search target in nums. If target exists, then return its index, otherwise return -1...
2019-12-22 05:14:22 157
原创 LeetCode BinarySearch 278 first bad version
Leetcode 278 first bad versionYou are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each ve...
2019-12-22 04:28:29 64
原创 LeetCode BinarySearch 34 Find First and Last Position of Element in Sorted Array
34. Find First and Last Position of Element in Sorted ArrayGiven an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.Your algorithm’s r...
2019-12-22 03:48:29 49
原创 LeetCode Backtracking 46 Permutations 47 Permutationsll
46. PermutationsGiven a collection of distinct integers, return all possible permutations.Example:Input: [1,2,3]Output:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]solution由于是要得到所有的排...
2019-12-22 00:53:46 94
原创 LeetCode DFS 78 Subsets 90 Subsets ll
SubsetsGiven a set of distinct integers, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.Example:Input: nums = [1,2,3]Output:[[3],...
2019-12-21 13:24:29 91
原创 LeetCodeBasics .length() .length .size() .add() .put()
1 .length()String,2 .lengthint[], char[],3 .size()ArratList, HashMap4 .add()HashSet, ArratList,5 .put()HashMap,
2019-12-21 12:18:06 79
原创 LeetCode Array 289 Game of Life
289. Game of Life (Medium)According to the Wikipedia’s article: “The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.”...
2019-12-21 09:19:26 95
原创 LeetCode String 32 Longest Valid Parentheses
32. Longest Valid ParenthesesGiven a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.Example 1:Input: “(()”Output: 2Exp...
2019-12-20 11:08:00 154
原创 LeetCode String 22 Generate Parentheses
22. Generate ParenthesesGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[“((()))”,“(()())”,“(()...
2019-12-20 01:13:19 94
原创 LeetCode String 20 Valid Parentheses
20. Valid ParenthesesGiven a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.An input string is valid if:Open brackets must be closed b...
2019-12-19 14:31:16 60
原创 LeetCode String 336 Palindrome Pairs
336. Palindrome PairsGiven a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome.E...
2019-12-19 14:05:45 105
原创 LeetCode String 5 Longest Palindromic Substring
5. Longest Palindromic SubstringGiven a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example 1:Input: “babad”Output: “bab”Note: “aba”...
2019-12-19 10:41:23 91
原创 LeetCode String 125 Valid Palindrome
125. Valid PalindromeGiven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note: For the purpose of this problem, we define empty string as val...
2019-12-19 08:46:24 79
原创 LeetCode String 76 Minimum Window Substring
76. Minimum Window SubstringGiven a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).Example:Input: S = “ADOBECODEBANC”, T = “ABC”...
2019-12-19 07:24:51 63
原创 LeetCode String 65 Valid Number
65. Valid NumberValidate if a given string can be interpreted as a decimal number.Some examples:“0” => true" 0.1 " => true“abc” => false“1 a” => false“2e10” => true" -90e3 " =...
2019-12-19 05:34:12 70
原创 LeetCode String 68 Text Justification
68. Text JustificationGiven an array of words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified.You should pack your w...
2019-12-19 04:41:33 63
原创 LeetCode String 157 158 Read N Characters Given Read4 I and II
157. Read N Characters Given Read4Given a file and assume that you can only read the file using a given method read4, implement a method to read n characters.Method read4:The API read4 reads 4 cons...
2019-12-19 01:17:16 131
原创 LeetCode String 273 Integer to English Words
273. Integer to English WordsConvert a non-negative integer to its english words representation. Given input is guaranteed to be less than 2312^{31}231 - 1.Example 1:Input: 123Output: “One Hundred...
2019-12-18 09:18:35 78
原创 LeetCode String 12 Integer to Roman
12. Integer to RomanRoman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C ...
2019-12-18 08:57:22 72
原创 LeetCode String 13 Roman to Integer
13. Roman to IntegerRoman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C ...
2019-12-18 00:18:54 89
原创 LeetCode String 171 Excel Sheet Column Number
171. Excel Sheet Column NumberGiven a column title as appear in an Excel sheet, return its corresponding column number.For example:A -> 1B -> 2C -> 3...Z -> 26AA -> 27AB -> ...
2019-12-17 23:58:23 78
原创 LeetCode String 168 Excel Sheet Column Title
168. Excel Sheet Column TitleGiven a positive integer, return its corresponding column title as appear in an Excel sheet.For example:1 -> A2 -> B3 -> C…26 -> Z27 -> AA28 -> ...
2019-12-06 04:22:52 57
原创 LeetCode String 316 Remove Duplicate Letters
316. Remove Duplicate LettersGiven a string which contains only lowercase letters, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smal...
2019-12-06 03:52:26 82
原创 LeetCode String 38 Count and Say
38. Count and SayThe count-and-say sequence is the sequence of integers with the first five terms as following:1112112111112211 is read off as “one 1” or 11.11 is read off as ...
2019-12-01 12:46:49 72
原创 LeetCode String 161 One Edit Distance
161. One Edit DistanceGiven two strings s and t, determine if they are both one edit distance apart.Note:There are 3 possiblities to satisify one edit distance apart:Insert a character into s to g...
2019-12-01 11:32:43 90
原创 LeetCode String 6 ZigZag Conversion
6. ZigZag ConversionThe 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)And t...
2019-12-01 06:11:12 50
原创 LeetCode String 179 Largest Number
179. Largest NumberGiven a list of non negative integers, arrange them such that they form the largest number.Example 1:Input: [10,2]Output: “210”Example 2:Input: [3,30,34,5,9]Output: “9534330”...
2019-12-01 04:16:31 84
原创 LeetCode String 87 Scramble String
87. Scramble StringGiven 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”:To scramb...
2019-12-01 01:43:13 77
原创 LeetCode String 49 Group Anagrams
49. Group AnagramsGiven an array of strings, group anagrams together.Example:Input: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”],Output:[[“ate”,“eat”,“tea”],[“nat”,“tan”],[“bat”]]Note:All inp...
2019-11-30 02:55:50 76
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人