- 博客(18)
- 资源 (1)
- 收藏
- 关注
原创 LeetCode 1110. Delete Nodes And Return Forest
Given therootof a binary tree, each node in the tree has a distinct value.After deletingall nodes with a value into_delete, we are left with a forest (adisjoint union of trees).Return the roots of the trees in the remaining forest. You may return...
2020-05-31 20:46:21 224
原创 LeetCode 1240. Tiling a Rectangle with the Fewest Squares 瓷砖
Given a rectangle of sizenxm, find the minimum number of integer-sided squares that tile the rectangle.Example 1:Input: n = 2, m = 3Output: 3Example 2:Input: n = 5, m = 8Output: 5Example 3:Input: n = 11, m = 13Output: 6...
2020-05-30 16:00:48 287
原创 LeetCode 1352. Product of the Last K Numbers 前缀法处理特殊值
Implement the classProductOfNumbersthat supports two methods:1.add(int num)Adds the numbernumto the back of the current list of numbers.2.getProduct(int k)Returns the product of the lastknumbers in the current list. You can assume that alwa...
2020-05-28 20:38:49 230
原创 LeetCode 1293. Shortest Path in a Grid with Obstacles Elimination 下一层坑
Given am * ngrid, where each cell is either0(empty)or1(obstacle).In one step, you can move up, down, left or right from and to an empty cell.Return the minimum number of steps to walk from the upper left corner(0, 0)to the lower right corner(m...
2020-05-28 20:12:40 293
原创 LeetCode 410. Split Array Largest Sum DP 二分
Given an array which consists of non-negative integers and an integerm, you can split the array intomnon-empty continuous subarrays. Write an algorithm to minimize the largest sum among thesemsubarrays.Note:Ifnis the length of array, assume the f...
2020-05-26 23:52:39 192
原创 LeetCode 1129. Shortest Path with Alternating Colors 图着色
Consider a directed graph, with nodes labelled0, 1, ..., n-1. In this graph, each edge is either red or blue, and there couldbe self-edges or parallel edges.Each[i, j]inred_edgesdenotes a red directed edge from nodeito nodej. Similarly, each[...
2020-05-24 17:31:34 217
原创 LeetCode 1042. Flower Planting With No Adjacent 染色
You haveNgardens, labelled1toN. In each garden, you want to plant one of 4 types of flowers.paths[i] = [x, y]describes the existence of a bidirectional path from gardenxto gardeny.Also, there is no garden that has more than 3 paths coming int...
2020-05-24 11:22:42 194
原创 LeetCode 842. Split Array into Fibonacci Sequence
Given a stringSof digits, such asS = "123456579", we can split it into aFibonacci-like sequence[123, 456, 579].Formally, a Fibonacci-like sequence is a listFof non-negative integers such that:0 <= F[i] <= 2^31 - 1, (that is,each integer f...
2020-05-23 22:42:34 213
原创 LeetCode 818. Race Car 折返剪枝
Your car starts at position 0 and speed +1 on an infinite number line. (Your car can go into negative positions.)Your car drives automatically according to a sequence of instructions A (accelerate) and R (reverse).When you get an instruction "A", your.
2020-05-23 19:54:44 389
原创 python 文件处理 [Debug]
import globimport osdef delete_dup_files(): items = glob.glob(r"E:\**\*", recursive=True) print(items) files_dic = {} print('Action\t{0}\t{1}'.format('FileName', 'Dup With')) for item in items: if (os.path.isfile(item)): .
2020-05-19 23:32:19 212
转载 Swift 弱引用 (weak )与 无主引用 (unowned )的区别 [Debug]
1.先举一个循环引用的列子class Example { var num = 10 var method:(Int) -> Int = { (i:Int) in return self.num + i } deinit { print("Example被释放了") }}method 是一个闭包类型的参数,在类的定义中被初始化为与类属性 num 进行加法的运算。使用Example:var example:Example? = Example()examp
2020-05-19 11:49:50 604
原创 LeetCode 856. Score of Parentheses 栈顶
Given a balanced parentheses stringS, compute the score of the string based on the following rule:()has score 1 ABhas scoreA + B, where A and B are balanced parentheses strings. (A)has score2 * A, where A is a balanced parentheses string.Exam...
2020-05-12 17:38:24 206
原创 LeetCode 1191. K-Concatenation Maximum Sum
Given an integer arrayarrand an integerk, modify the array by repeating itktimes.For example, ifarr= [1, 2]andk = 3then the modified array will be[1, 2, 1, 2, 1, 2].Return the maximum sub-array sum in the modified array. Note that the len...
2020-05-11 22:51:25 181
原创 LeetCode 1109. Corporate Flight Bookings
There arenflights, and they are labeledfrom1ton.We have a list of flight bookings. Thei-th bookingbookings[i] = [i, j, k]means that we bookedkseats from flights labeleditojinclusive.Return an arrayanswerof lengthn, representing the n...
2020-05-10 23:04:59 182
原创 LeetCode 1103. Distribute Candies to People 二分求和推公式
We distribute somenumber ofcandies, to a row ofn =num_peoplepeople in the following way:We then give 1 candy to the first person, 2 candies to the second person, and so on until we givencandies to the last person.Then, we go back to the start of...
2020-05-10 19:30:35 182
原创 LeetCode 460. LFU Cache 顺带总结一下LRU
Design and implement a data structure forLeast Frequently Used (LFU)cache. It should support the following operations:getandput.get(key)- Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.put(key...
2020-05-09 14:07:36 357
原创 LeetCode 887. Super Egg Drop 扔鸡蛋问题四种方法
You are givenKeggs, and you have access to a building withNfloors from1toN.Each egg is identical in function, and if an egg breaks, you cannot drop itagain.You know that there exists a fl...
2020-05-08 12:08:21 529
原创 LeetCode 1111. Maximum Nesting Depth of Two Valid Parentheses Strings
A string is avalid parentheses string(denoted VPS) if and only if it consists of"("and")"characters only, and:It is the empty string, or It can be written asAB(Aconcatenated withB), whe...
2020-05-01 11:01:14 236
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人