- 博客(74)
- 收藏
- 关注
原创 九章算法 强化 Lecture 5 DP上滚动数组 划分型 博弈型 区间型
滚动数组 110 确定状态 研究最优策略的最后一步 转化为子问题 转移方程 根据子问题定义直接得到 初始条件和边界情况 仔细,考虑周全 计算顺序 利用之前的计算结果 划分型动态规划 512 676 博弈动态规划 395 区间型动态规划 求一段区间的最大最小值 168 ...
2020-03-02 05:16:43
246
原创 九章算法 强化 Lecture 4 扫描线二分法双端队列
扫描线 例题 LintCode 391. Number of Airplanes in the Sky Given 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
558
原创 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
234
原创 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
165
原创 LeetCode BinarySearch 852. Peak Index in a Mountain Array 1095. Find in Mountain Array
852. Peak Index in a Mountain Array Let’s call an array A a mountain if the following properties hold: A.length >= 3 There exists some 0 < i < A.length - 1 such that A[0]<A[1]<...A[i−1...
2019-12-24 06:18:46
177
原创 LeetCode BinarySearch 162. Find Peak Element
162. Find Peak Element A 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
169
原创 LeetCode BinarySearch 240. Search a 2D Matrix II
240. Search a 2D Matrix II Write 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
150
原创 LeetCode BinarySearch 74 Search a 2D Matrix
74. Search a 2D Matrix Write 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
114
原创 Leetcode BinarySearch 302 Smallest Rectangle Enclosing Black Pixels
302. Smallest Rectangle Enclosing Black Pixels An 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
261
原创 LeetCode BinarySearch 33 & 81 Search in Rotated Sorted Array I II
33. Search in Rotated Sorted Array Suppose 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
176
原创 Leetcode BinarySearch 153 154 Find Minimum in Rotated Sorted Array l & ll
153. Find Minimum in Rotated Sorted Array Suppose 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
115
原创 LeetCode BinarySearch 702 Search in a Sorted Array of Unknown Size
702. Search in a Sorted Array of Unknown Size Given 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
222
原创 LeetCode BinarySearch 278 first bad version
Leetcode 278 first bad version You 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
136
原创 LeetCode BinarySearch 34 Find First and Last Position of Element in Sorted Array
34. Find First and Last Position of Element in Sorted Array Given 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
116
原创 LeetCode Backtracking 46 Permutations 47 Permutationsll
46. Permutations Given 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
162
原创 LeetCode DFS 78 Subsets 90 Subsets ll
Subsets Given 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
153
原创 LeetCodeBasics .length() .length .size() .add() .put()
1 .length() String, 2 .length int[], char[], 3 .size() ArratList, HashMap 4 .add() HashSet, ArratList, 5 .put() HashMap,
2019-12-21 12:18:06
140
原创 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
166
原创 LeetCode String 32 Longest Valid Parentheses
32. Longest Valid Parentheses Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring. Example 1: Input: “(()” Output: 2 Exp...
2019-12-20 11:08:00
225
原创 LeetCode String 22 Generate Parentheses
22. Generate Parentheses Given 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
146
原创 LeetCode String 20 Valid Parentheses
20. Valid Parentheses Given 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
108
原创 LeetCode String 336 Palindrome Pairs
336. Palindrome Pairs Given 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
189
原创 LeetCode String 5 Longest Palindromic Substring
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 1: Input: “babad” Output: “bab” Note: “aba”...
2019-12-19 10:41:23
154
原创 LeetCode String 125 Valid Palindrome
125. Valid Palindrome Given 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
122
原创 LeetCode String 76 Minimum Window Substring
76. Minimum Window Substring Given 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
117
原创 LeetCode String 65 Valid Number
65. Valid Number Validate 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
125
原创 LeetCode String 68 Text Justification
68. Text Justification Given 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
113
原创 LeetCode String 157 158 Read N Characters Given Read4 I and II
157. Read N Characters Given Read4 Given 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
183
原创 LeetCode String 273 Integer to English Words
273. Integer to English Words Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 2312^{31}231 - 1. Example 1: Input: 123 Output: “One Hundred...
2019-12-18 09:18:35
141
原创 LeetCode String 12 Integer to Roman
12. Integer to Roman Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C ...
2019-12-18 08:57:22
120
原创 LeetCode String 13 Roman to Integer
13. Roman to Integer Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C ...
2019-12-18 00:18:54
151
原创 LeetCode String 171 Excel Sheet Column Number
171. Excel Sheet Column Number Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> ...
2019-12-17 23:58:23
128
原创 LeetCode String 168 Excel Sheet Column Title
168. Excel Sheet Column Title Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 -> A 2 -> B 3 -> C … 26 -> Z 27 -> AA 28 -> ...
2019-12-06 04:22:52
102
原创 LeetCode String 316 Remove Duplicate Letters
316. Remove Duplicate Letters Given 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
148
原创 LeetCode String 38 Count and Say
38. Count and Say The count-and-say sequence is the sequence of integers with the first five terms as following: 1 11 21 1211 111221 1 is read off as “one 1” or 11. 11 is read off as ...
2019-12-01 12:46:49
130
原创 LeetCode String 161 One Edit Distance
161. One Edit Distance Given 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
142
原创 LeetCode String 6 ZigZag Conversion
6. ZigZag Conversion The 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
97
原创 LeetCode String 179 Largest Number
179. Largest Number Given 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
138
原创 LeetCode String 87 Scramble String
87. Scramble String Given 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
144
原创 LeetCode String 49 Group Anagrams
49. Group Anagrams Given 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
133
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅