*博客头图：

RGB颜色，例如：#AFAFAF

Hover：

RGB颜色，例如：#AFAFAF

RGB颜色，例如：#AFAFAF

# taoqick的专栏

• 博客(668)
• 资源 (1)
• 论坛 (1)
• 收藏
• 关注

#### 原创 LeetCode 1032. Stream of Characters 4行Trie树

Implement theStreamCheckerclass as follows:StreamChecker(words): Constructor, init the data structure with the given words. query(letter): returns true if and only if for somek >= 1, the lastkcharacters queried (in order from oldest to newest, i...

2021-01-04 00:25:36 38

#### 原创 Python中的map() reduce() filter() Trie树简短

python 中的for 循环和while 循环的效率比较低。如果遇到循环时，尽量使用map() reduce() filter()。这三个函数的运行速度比较快：map()函数他接收一个函数和一个序列。在python3 中返回一个map对象。在python2 中返回一个列表：b=map(lambda x:print("中秋快乐%s"%x),[1,2,3])b3 = map(lambda x:x*2,range(10)) #相当于 [ i*2 for i in range(10)]print(ls

2021-01-04 00:13:24 37

#### 原创 LeetCode 741. Cherry Pickup 传纸条 动态规划

You are given an n x n grid representing a field of cherries, each cell is one of three possible integers.0 means the cell is empty, so you can pass through,1 means the cell contains a cherry that you can pick up and pass through, or-1 means the cell co

2020-12-27 22:08:55 15

#### 原创 Python打印某个对象的成员变量值[Debug]

2020-12-11 10:32:59 46

#### 原创 LeetCode 480. Sliding Window Median 延迟双堆

Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean of the two middle value.Examples:[2,3,4], the median is3[2,3], the median is(2 + 3) / 2 = 2.5Given an arr...

2020-12-06 23:22:43 10

#### 原创 LeetCode 871. Minimum Number of Refueling Stops 动态规划类似背包 贪心

A car travels from a starting position to a destination which istargetmiles east of the starting position.Along the way, there are gas stations. Eachstation[i]represents a gas station that isstation[i][0]miles east of the starting position, and ha...

2020-11-29 16:27:22 12

#### 原创 python2 存csv和中文处理 [Debug]

2020-11-17 14:35:52 17

#### 原创 LeetCode 174. Dungeon Game 逆序动态规划

The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially positioned in the top-left room and must fight his way thro

2020-11-15 23:49:29 20

1，包含a和b： ^(?=.*a)(?=.*b).*$2，包含a不包含b： ^((?!b.)*a((?!b).)*$ 例:包含admin且不包含abc。 ^((?!abc).)*admin((?!abc).)*$3，包含a不包含b和c： ^((?!b|c).)... 2020-11-14 17:18:57 127 #### 原创 vim 粘贴乱缩进 编辑模式粘贴 [Debug] 方法一：在命令模式下输入:set paste然后输入i，再在编辑模式下粘贴，这样不会乱锁紧方法二：vim --version | grep "clipboard"查看vim是不是支持clipboard，很多vim不支持，这条基本行不通：https://blog.csdn.net/zhangxiao93/article/details/53677764... 2020-11-10 16:04:34 12 #### 原创 LeetCode 1031. Maximum Sum of Two Non-Overlapping Subarrays滑动窗口 前缀和 Given an arrayAof non-negative integers, return the maximum sum of elements in two non-overlapping (contiguous) subarrays, which have lengthsLandM. (For clarification, theL-length subarray could occur before or after theM-length subarray.)Formall... 2020-11-03 23:28:42 69 #### 原创 LeetCode 1326. Minimum Number of Taps to Open to Water a Garden 动态规划 离散化 贪心 There is a one-dimensional garden on the x-axis. The garden starts at the point0and ends at the pointn. (i.e The length of the garden isn).There aren + 1taps locatedat points[0, 1, ..., n]in the garden.Given an integernand an integer arrayra... 2020-10-22 23:58:06 83 #### 原创 LeetCode 925. Long Pressed Name 有坑 Your friend is typing hisnameinto a keyboard. Sometimes, when typing a characterc, the key might getlong pressed, and the character will be typed 1 or more times.You examine thetypedcharacters of the keyboard. ReturnTrueif it is possible that i... 2020-10-15 22:51:50 29 #### 原创 LeetCode 1209. Remove All Adjacent Duplicates in String II 有坑 Given a strings, akduplicate removalconsists of choosingkadjacent and equal letters fromsand removingthem causing the left and the right side of the deleted substring to concatenate together.We repeatedly makekduplicate removals onsuntil we ... 2020-10-14 23:56:23 93 #### 原创 LeetCode 767. Reorganize String Python字符串 Given a stringS, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.If possible, output any possible result. If not possible, return the empty string.Example 1:Input: S = "aab"Output: "a.. 2020-10-11 23:54:45 47 #### 原创 LeetCode 652. Find Duplicate Subtrees 递归小坑 Given therootof a binary tree, return allduplicate subtrees.For each kind of duplicate subtrees, you only need to return the root node of anyoneof them.Two trees areduplicateif they have thesame structurewith thesame node values.Example ... 2020-10-11 17:46:49 30 #### 原创 LeetCode 274. H-Index 二分 Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to thedefinition of h-index on Wikipedia: "A scientist has indexhifhof his/herNpapers haveat lea... 2020-10-11 14:49:23 23 #### 原创 LeetCode 1277. Count Square Submatrices with All Ones 二维前缀 Given am * nmatrix of ones and zeros, return how manysquaresubmatrices have all ones.Example 1:Input: matrix =[ [0,1,1,1], [1,1,1,1], [0,1,1,1]]Output: 15Explanation: There are 10 squares of side 1.There are 4 squares of side 2.The... 2020-10-11 12:23:25 20 #### 原创 LeetCode 959. Regions Cut By Slashes 并查集 In a N x Ngridcomposed of 1 x 1 squares, each 1 x 1 square consists of a/,\, or blank space. These characters divide the square into contiguous regions.(Note that backslash characters are escaped, so a\is represented as"\\".)Return the number o... 2020-10-09 23:22:50 13 #### 转载 Mac和Eclipse不同版本JDK切换 [Debug] mac上最终安装目录(版本号根据情况略有不同)JDK 1.6：/Library/Java/JavaVirtualMachines/1.6.0.jdkJDK 1.7：/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdkJDK 1.8：/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk所以主要是改JAVA_HOME和PATH:export JAVA_6_HOME=`/usr/libexec/java 2020-09-30 11:35:57 56 #### 原创 LeetCode 844. Backspace String Compare 坑 Given twostringsSandT,return if they are equal when both are typed into empty text editors.#means a backspace character.Note that afterbackspacing an empty text, the text will continue empty.Example 1:Input: S = "ab#c", T = "ad#c"Output: tr... 2020-09-21 23:48:57 12 #### 原创 Python sys.path, PYTHONPATH和PATH的关系 [Debug] 简单来说，Python运行时的包会去sys.path找，而sys.path这个数组会从前到后找，优先级以此是：文件本身的路径 系统环境变量PYTHONPATH的路径 系统环境变量PATH里指定的anaconda的安装路径可以用以下脚本进行一下测试：import osimport sysprint("os.environ['PYTHONPATH']={0}".format(os.environ['PYTHONPATH']))print("os.environ['PATH']={0}".f 2020-09-08 13:48:11 46 #### 原创 ssh 免密登录 指定账户【Debug】 步骤1：# 即使本机器的用户名是b，也可以使用ssh a@IP登录IP的机器，直接ssh IP是以b的用户名登录$ ssh-keygen -t rsa -C "a"步骤2：在IP机器的~/.ssh/authorized_keys中追加刚才生成的公钥.pub（文件可能不存在，需要创建）...

2020-09-05 22:51:03 35

#### 原创 1145. Binary Tree Coloring Game 树上博弈

Two players play a turn based game on a binary tree. We are giventhe root of this binary tree, and the number of nodes nin the tree. n is odd, andeach node has a distinct value from 1 to n.Initially, the first player names a value x with 1 <= x &...

2020-08-29 13:56:08 53

#### 原创 LeetCode 729. My Calendar I 红黑树 线段树 二分查找树

Implement a MyCalendar class to store your events. A new event can be added if adding the event will not cause a double booking.Your class will have the method, book(int start, int end). Formally, this represents a booking on the half open interval [star

2020-08-26 11:58:39 56

#### 原创 LeetCode 354. Russian Doll Envelopes 最长递增子序列 Trick

You have a number of envelopes with widths and heights given as a pair of integers (w, h). One envelope can fit into another if and only if both the width and height of one envelope is greater than the width and height of the other envelope.What is the m

2020-08-25 15:09:42 27

#### 原创 LeetCode 375. Guess Number Higher or Lower II 扔鸡蛋变种

We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I picked.Every time you guess wrong, I'll tell you whether the number I picked is higher or lower.However, when you guess a particular n

2020-08-21 18:09:10 29

#### 原创 LeetCode 792. Number of Matching Subsequences 桶排序

Given string S and adictionary of words words, find the number of words[i] that is a subsequence of S.Example :Input: S = "abcde"words = ["a", "bb", "acd", "ace"]Output: 3Explanation: There are three words in words that are a subsequence ofS : "..

2020-08-19 19:19:56 41

#### 原创 Cloud9 c9sdk的使用【Debug】

Cloud9是Amazon出的一款浏览器IDE方便访问linux机器。简单总结一下步骤：安装：安装过程中会依赖gcc和python2.7，需要提前装好：git clone https://github.com/c9/core.git c9sdkcd c9sdkscripts/install-sdk.sh启动：sudo node server.js -p 8080 --listen IP -a username:"password" -w /其中IP是本机的IP，p是端口，w是wo

2020-08-19 12:07:56 67

#### 原创 LeetCode 840. Magic Squares In Grid 找规律

A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum.Given an gridof integers, how many 3 x 3 "magic square" subgrids are there? (Each subgrid is contiguous)...

2020-08-18 15:50:58 33

#### 原创 LeetCode 552. Student Attendance Record II 斐波拉契 log(n)

Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, return it after mod 109 + 7.A student attendance record is a string that only contains the

2020-08-11 15:52:30 32

#### 原创 LeetCode 837. New 21 Game 滑动窗口 逆向动态规划

Alice plays the following game, loosely based on the card game "21".Alice starts with 0 points, and draws numbers while she has less than K points. During each draw, she gains an integer number of points randomly from the range [1, W], where W is an int.

2020-08-11 14:55:36 37

#### 原创 LeetCode 743. Network Delay Time Dijstrala BFS版 DFS版

There are N network nodes, labelled 1 to N.Given times, a list of travel times as directed edges times[i] = (u, v, w), where u is the source node, v is the target node, and w is the time it takes for a signal to travel from source to target.Now, we sen

2020-08-11 14:24:22 48

#### 原创 LeetCode 593. Valid Square 平面四点能否正方形

Given the coordinates of four points in 2D space, return whether the four points could construct a square.The coordinate (x,y) of a point is represented by an integer array with two integers.Example:Input: p1 = [0,0], p2 = [1,1], p3 = [1,0], p4 = [0

2020-08-11 14:15:13 35

#### 原创 Mac安装windows双系统 U盘【Debug】

2020-08-04 23:17:36 64

#### 原创 LeetCode 803. Bricks Falling When Hit 时光倒流 注意标记

We have a grid of 1s and 0s; the 1s in a cell represent bricks. A brick will not drop if and only if it is directly connected to the top of the grid, or at least one of its (4-way) adjacent bricks will not drop.We will do some erasuressequentially. Eac..

2020-08-04 22:43:39 41

#### 原创 LeetCode 1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit 双端队列 deque

Given anarray of integers nums and aninteger limit, return the size of the longest non-empty subarray such that the absolute difference between any two elements of this subarray is less than or equal tolimit.Example 1:Input: nums = [8,2,4,7], li...

2020-08-04 15:09:02 51

#### 原创 LeetCode 1292. Maximum Side Length of a Square with Sum Less than or Equal to Threshold 1074. 二维前缀

Given a m x nmatrix mat and an integer threshold. Return the maximum side-length of a square with a sum less than or equal to threshold or return 0 if there is no such square.Example 1:Input: mat = [[1,1,3,2,4,3,2],[1,1,3,2,4,3,2],[1,1,3,2,4,3,2..

2020-08-02 00:00:35 49

#### 原创 LeetCode 914. X of a Kind in a Deck of Cards gcd 辗转相除 reduce

In a deck of cards, each card has an integer written on it.Return true if and only if you can chooseX >= 2 such thatit is possible to split the entire deckinto 1 or more groups of cards, where:Each group has exactly X cards. All the cards in eac...

2020-07-25 15:38:56 46

#### 原创 LeetCode 1146. Snapshot Array 二分 空

Implement a SnapshotArray that supports the following interface:SnapshotArray(int length) initializes an array-like data structure with the given length. Initially, each element equals 0.void set(index, val) sets the element at the given index to be eq.

2020-07-21 22:40:35 43

2014-05-29

#### taoqick的留言板

###### 空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人 TA的粉丝