Fork me on GitHub
摘要:终于将LeetCode的大部分题刷完了,真是漫长的第一遍啊,估计很多题都忘的差不多了,这次开个题目汇总贴,并附上每道题目的解题连接,方便之后查阅吧~ 对应的 Github 项目的同步地址如下,欢迎大家关注点赞❤️ https://github.com/grandyang/leetcode 如果各位看 阅读全文
posted @ 2015-06-28 23:20 Grandyang 阅读(1060072) 评论(155) 推荐(111) 编辑
摘要:A string is a valid parentheses string (denoted VPS) if and only if it consists of "(" and ")" characters only, and: It is the empty string, or It can 阅读全文
posted @ 2021-05-09 22:38 Grandyang 阅读(12) 评论(0) 推荐(0) 编辑
摘要:Given the root of a binary tree, each node in the tree has a distinct value. After deleting all nodes with a value in to_delete, we are left with a fo 阅读全文
posted @ 2021-05-09 02:33 Grandyang 阅读(51) 评论(0) 推荐(0) 编辑
摘要:There are n flights that are labeled from 1 to n. You are given an array of flight bookings bookings, where bookings[i] = [firsti, lasti, seatsi] repr 阅读全文
posted @ 2021-05-06 12:25 Grandyang 阅读(11) 评论(0) 推荐(0) 编辑
摘要:Given a valid (IPv4) IP address, return a defanged version of that IP address. A defanged IP address replaces every period "." with "[.]". Example 1: 阅读全文
posted @ 2021-05-05 12:48 Grandyang 阅读(25) 评论(0) 推荐(0) 编辑
摘要:Return the result of evaluating a given boolean expression, represented as a string. An expression can either be: "t", evaluating to True; "f", evalua 阅读全文
posted @ 2021-05-02 06:41 Grandyang 阅读(15) 评论(0) 推荐(0) 编辑
摘要:When you run hexo g, you might get the following error: call_and_retry_last allocation failed - javascript heap out of memory Solution: Try to run exp 阅读全文
posted @ 2021-04-26 02:50 Grandyang 阅读(19) 评论(0) 推荐(0) 编辑
摘要:We have a sequence of books: the i-th book has thickness books[i][0] and height books[i][1]. We want to place these books in order onto bookcase shelv 阅读全文
posted @ 2021-04-22 15:56 Grandyang 阅读(44) 评论(0) 推荐(0) 编辑
摘要:When use nginx to configure https with ssl 443 port, it might be timed out, but your http 80 port work correctly. At this time, if you nginx configure 阅读全文
posted @ 2021-04-20 16:15 Grandyang 阅读(26) 评论(0) 推荐(0) 编辑
摘要:In an infinite binary tree where every node has two children, the nodes are labelled in row order. In the odd numbered rows (ie., the first, third, fi 阅读全文
posted @ 2021-04-15 15:55 Grandyang 阅读(43) 评论(0) 推荐(0) 编辑
摘要:Once you deployed the hexo with Nginx on your web instance, you might get the 403 forbidden error, try the following step to fix: Solution: Run vim /e 阅读全文
posted @ 2021-04-11 17:18 Grandyang 阅读(36) 评论(0) 推荐(0) 编辑
摘要:When you run hexo g on any web instances, like on AWS or Azure, you might get the following error: (node:3568) ExperimentalWarning: The fs.promises AP 阅读全文
posted @ 2021-04-11 10:07 Grandyang 阅读(22) 评论(0) 推荐(0) 编辑
摘要:We distribute some number of candies, to a row of n = num_people people in the following way: We then give 1 candy to the first person, 2 candies to t 阅读全文
posted @ 2021-04-09 16:24 Grandyang 阅读(43) 评论(0) 推荐(0) 编辑
摘要:Under a grammar given below, strings can represent a set of lowercase words. Let's use R(expr) to denote the set of words the expression represents. G 阅读全文
posted @ 2021-04-07 14:32 Grandyang 阅读(71) 评论(0) 推荐(0) 编辑
摘要:(This problem is an interactive problem.) You may recall that an array A is a mountain array if and only if: A.length >= 3 There exists some i with 0 阅读全文
posted @ 2021-04-04 16:10 Grandyang 阅读(61) 评论(0) 推荐(0) 编辑
摘要:When running hexo server, you might get the following error: console.js:35 throw new TypeError('Console expects a writable stream instance'); ^ TypeEr 阅读全文
posted @ 2021-04-03 15:05 Grandyang 阅读(33) 评论(0) 推荐(0) 编辑
摘要:Sometimes your hexo environment may get fucked up, may give you the following errors: ERROR Local hexo not found in /YourProjectPath/ ERROR Try runnin 阅读全文
posted @ 2021-04-03 13:56 Grandyang 阅读(65) 评论(7) 推荐(0) 编辑
摘要:You are driving a vehicle that has capacity empty seats initially available for passengers. The vehicle only drives east (ie. it cannot turn around an 阅读全文
posted @ 2021-04-02 13:04 Grandyang 阅读(74) 评论(0) 推荐(0) 编辑
摘要:You are given a large sample of integers in the range [0, 255]. Since the sample is so large, it is represented by an array count where count[k] is th 阅读全文
posted @ 2021-04-01 15:33 Grandyang 阅读(39) 评论(0) 推荐(0) 编辑
摘要:Given two strings str1 and str2, return the shortest string that has both str1 and str2 as subsequences. If multiple answers exist, you may return any 阅读全文
posted @ 2021-03-30 15:44 Grandyang 阅读(75) 评论(0) 推荐(0) 编辑
摘要:Given an n x n binary matrix grid, return the length of the shortest clear path in the matrix. If there is no clear path, return -1. A clear path in a 阅读全文
posted @ 2021-03-29 03:52 Grandyang 阅读(72) 评论(0) 推荐(0) 编辑
摘要:We have a set of items: the i-th item has value values[i] and label labels[i]. Then, we choose a subset S of these items, such that: |S| <= num_wanted 阅读全文
posted @ 2021-03-28 14:59 Grandyang 阅读(483) 评论(0) 推荐(0) 编辑
摘要:Given a fixed length array arr of integers, duplicate each occurrence of zero, shifting the remaining elements to the right. Note that elements beyond 阅读全文
posted @ 2021-03-28 12:30 Grandyang 阅读(205) 评论(0) 推荐(0) 编辑
摘要:We can rotate digits by 180 degrees to form new digits. When 0, 1, 6, 8, 9 are rotated 180 degrees, they become 0, 1, 9, 8, 6 respectively. When 2, 3, 阅读全文
posted @ 2021-03-28 12:24 Grandyang 阅读(148) 评论(0) 推荐(0) 编辑
摘要:On a campus represented as a 2D grid, there are N workers and M bikes, with N <= M. Each worker and bike is a 2D coordinate on this grid. Our goal is 阅读全文
posted @ 2021-03-28 12:20 Grandyang 阅读(113) 评论(0) 推荐(0) 编辑
摘要:Given a number N, return true if and only if it is a confusing number, which satisfies the following condition: We can rotate digits by 180 degrees to 阅读全文
posted @ 2021-03-28 12:19 Grandyang 阅读(69) 评论(0) 推荐(0) 编辑
摘要:From any string, we can form a subsequence of that string by deleting some number of characters (possibly no deletions). Given two strings source and  阅读全文
posted @ 2021-03-28 12:18 Grandyang 阅读(189) 评论(0) 推荐(0) 编辑
摘要:Return the lexicographically smallest subsequence of s that contains all the distinct characters of s exactly once. Note: This question is the same as 阅读全文
posted @ 2021-03-28 12:07 Grandyang 阅读(128) 评论(0) 推荐(0) 编辑
摘要:Given the root of a binary tree, consider all root to leaf paths: paths from the root to any leaf. (A leaf is a node with no children.) A node is insu 阅读全文
posted @ 2021-03-28 12:05 Grandyang 阅读(58) 评论(0) 推荐(0) 编辑
摘要:You have n tiles, where each tile has one letter tiles[i] printed on it. Return the number of possible non-empty sequences of letters you can make usi 阅读全文
posted @ 2021-03-28 12:04 Grandyang 阅读(81) 评论(0) 推荐(0) 编辑
摘要:Given words first and second, consider occurrences in some text of the form "first second third", where second comes immediately after first, and thir 阅读全文
posted @ 2021-03-28 12:01 Grandyang 阅读(51) 评论(0) 推荐(0) 编辑
摘要:Given a matrix and a target, return the number of non-empty submatrices that sum to target. A submatrix x1, y1, x2, y2 is the set of all cells matrix[ 阅读全文
posted @ 2021-03-28 11:59 Grandyang 阅读(239) 评论(0) 推荐(0) 编辑
摘要:Given two numbers arr1 and arr2 in base -2, return the result of adding them together. Each number is given in array format: as an array of 0s and 1s, 阅读全文
posted @ 2021-03-28 11:57 Grandyang 阅读(55) 评论(0) 推荐(0) 编辑
摘要:You are given an binary matrix . You can choose any number of columns in the matrix and flip every cell in that column (i.e., Change the value of the 阅读全文
posted @ 2021-03-16 15:52 Grandyang 阅读(95) 评论(0) 推荐(0) 编辑
摘要:For two strings and , we say " divides " if and only if ( concatenated with itself 1 or more times) Given two strings str1 and str2, return the larges 阅读全文
posted @ 2021-03-15 14:08 Grandyang 阅读(112) 评论(0) 推荐(0) 编辑
摘要:In a warehouse, there is a row of barcodes, where the barcode is . Rearrange the barcodes so that no two adjacent barcodes are equal. You may return a 阅读全文
posted @ 2021-03-13 16:24 Grandyang 阅读(80) 评论(0) 推荐(0) 编辑
摘要:Given an array of positive integers (not necessarily distinct), return the lexicographically largest permutation that is smaller than , that can be ma 阅读全文
posted @ 2021-03-12 14:13 Grandyang 阅读(103) 评论(0) 推荐(0) 编辑
摘要:Today, the bookstore owner has a store open for minutes. Every minute, some number of customers ( ) enter the store, and all those customers leave aft 阅读全文
posted @ 2021-03-09 17:19 Grandyang 阅读(113) 评论(0) 推荐(0) 编辑
摘要:Given a string , consider all duplicated substrings : (contiguous) substrings of s that occur 2 or more times. The occurrences may overlap. Return any 阅读全文
posted @ 2021-03-08 07:13 Grandyang 阅读(149) 评论(0) 推荐(0) 编辑
摘要:Students are asked to stand in non decreasing order of heights for an annual photo. Return the minimum number of students that must move in order for 阅读全文
posted @ 2021-03-05 13:34 Grandyang 阅读(85) 评论(0) 推荐(0) 编辑
摘要:You are given an array of integers where is the weight of the stone. We are playing a game with the stones. On each turn, we choose any two stones and 阅读全文
posted @ 2021-03-04 15:15 Grandyang 阅读(417) 评论(0) 推荐(0) 编辑
Fork me on GitHub