- 博客(20)
- 资源 (1)
- 收藏
- 关注
原创 LeetCode 542. 01 Matrix 中离最近0的距离
Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell.The distance between two adjacent cells is 1.Example 1:Input:[[0,0,0], [0,1,0], [0,0,0]]Output:[[0,...
2020-04-30 23:14:31 171
原创 LeetCode 466. Count The Repetitions 循环节
DefineS = [s,n]as the string S which consists of n connected strings s. For example,["abc", 3]="abcabcabc".On the other hand, we define that string s1 can be obtained from string s2 if we can re...
2020-04-30 12:31:59 194
原创 LeetCode 212. Word Search II 5行内Build Trie树
Given a 2D board and a list of words from the dictionary, find all words in the board.Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horiz...
2020-04-20 13:35:42 174
原创 LeetCode 857. Minimum Cost to Hire K Workers DP坑 反直觉
There areNworkers. Thei-th worker has aquality[i]and a minimum wage expectationwage[i].Now we want to hire exactlyKworkers to form apaid group. When hiring a group of K workers, we must p...
2020-04-19 23:03:11 154
原创 LeetCode 892. Surface Area of 3D Shapes
On aN*Ngrid, we place some1 * 1 * 1cubes.Each valuev = grid[i][j]represents a tower ofvcubes placed on top of grid cell(i, j).Return the total surface area of the resulting shapes....
2020-04-19 22:24:02 128
原创 LeetCode 930. Binary Subarrays With Sum LeetCode 前缀 双指针 坑
In an arrayAof0s and1s, how manynon-emptysubarrays have sumS?Example 1:Input: A = [1,0,1,0,1], S = 2Output: 4Explanation: The 4 subarrays are bolded below:[1,0,1,0,1][1,0,1,0,1][1...
2020-04-18 14:18:25 199
原创 LeetCode 587. Erect the Fence 凸包 向量叉积 Hadamard product
here are some trees, where each tree is represented by (x,y) coordinate in a two-dimensional garden. Your job is to fence the entire garden using theminimum lengthof rope as it is expensive. The gar...
2020-04-13 17:13:35 219
原创 LeetCode 975. Odd Even Jump 栈+预排序代替红黑树
You are given an integer arrayA. Fromsome starting index, you can make a series of jumps. The (1st, 3rd, 5th, ...)jumps in the series are calledodd numbered jumps, and the (2nd, 4th, 6th, ...) j...
2020-04-11 12:52:27 210
原创 LeetCode 454. 4Sum II
Given four lists A, B, C, D of integer values, compute how many tuples(i, j, k, l)there are such thatA[i] + B[j] + C[k] + D[l]is zero.To make problem a bit easier, all A, B, C, D have same lengt...
2020-04-10 10:38:17 116
原创 LeetCode 395. Longest Substring with At Least K Repeating Characters 假装双指针 分隔符
Find the length of the longest substringTof a given string (consists of lowercase letters only) such that every character inTappears no less thanktimes.Example 1:Input:s = "aaabb", k = 3...
2020-04-09 22:54:55 127
原创 LeetCode 384. Shuffle an Array
Shuffle a set of numbers without duplicates.Example:// Init an array with set 1, 2, and 3.int[] nums = {1,2,3};Solution solution = new Solution(nums);// Shuffle the array [1,2,3] and return i...
2020-04-09 13:26:32 102
原创 LeetCode 380. Insert Delete GetRandom O(1)
Design a data structure that supports all following operations inaverageO(1)time.insert(val): Inserts an item val to the set if not already present. remove(val): Removes an item val from the ...
2020-04-08 22:10:15 168
原创 LeetCode 341. Flatten Nested List Iterator
Given a nested list of integers, implement an iterator to flatten it.Each element is either an integer, or a list -- whose elements may also be integers or other lists.Example 1:Input: [[1,1],2...
2020-04-06 14:29:26 145
原创 LeetCode 329. Longest Increasing Path in a Matrix
Given an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside o...
2020-04-06 11:56:33 119
原创 LeetCode 315. Count of Smaller Numbers After Self 归并排序
You are given an integer arraynumsand you have to return a newcountsarray. Thecountsarray has the property wherecounts[i]is the number of smaller elements to the right ofnums[i].Example:...
2020-04-05 22:10:19 135
原创 LeetCode 324. Wiggle Sort II A(i)=(2*i+1)%(n|1) 荷兰国旗问题 & 376. Wiggle Subsequence & 280
Given an unsorted arraynums, reorder it such thatnums[0] < nums[1] > nums[2] < nums[3]....Example 1:Input: nums = [1, 5, 1, 1, 6, 4]Output: One possible answer is [1, 4, 1, 5, 1, 6]....
2020-04-04 21:17:40 177
原创 LeetCode 289. Game of Life
According to theWikipedia's article: "TheGame of Life, also known simply asLife, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."Given aboardwithmbyn...
2020-04-03 14:03:27 148
原创 LeetCode 621. Task Scheduler
Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks. Tasks could be done without original order. Each task could ...
2020-04-03 11:44:28 144
原创 LeetCode 739. Daily Temperatures 栈拧巴着放啥
Given a list of daily temperaturesT, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which...
2020-04-01 23:41:31 150
原创 LeetCode 581. Shortest Unsorted Continuous Subarray
Given an integer array, you need to find onecontinuous subarraythat if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too.You need to find ...
2020-04-01 17:48:41 119
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人