8 taoqick

尚未进行身份认证

暂无相关简介

等级
TA的排名 6k+

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

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

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

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

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

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

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

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

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

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

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

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

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

LeetCode 542. 01 Matrix

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

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

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

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

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

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

LeetCode 587. Erect the Fence 凸包 向量叉积

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

查看更多

勋章 我的勋章
  • 持之以恒
    持之以恒
    授予每个自然月内发布4篇或4篇以上原创或翻译IT博文的用户。不积跬步无以至千里,不积小流无以成江海,程序人生的精彩需要坚持不懈地积累!
  • 1024勋章
    1024勋章
    #1024程序员节#活动勋章,当日发布原创博客即可获得
  • 勤写标兵Lv4
    勤写标兵Lv4
    授予每个自然周发布9篇以上(包括9篇)原创IT博文的用户。本勋章将于次周周三上午根据用户上周的博文发布情况由系统自动颁发。