Fork me on GitHub
摘要:终于将LeetCode的大部分题刷完了,真是漫长的第一遍啊,估计很多题都忘的差不多了,这次开个题目汇总贴,并附上每道题目的解题连接,方便之后查阅吧~ 对应的 Github 项目的同步地址如下,欢迎大家关注点赞❤️ https://github.com/grandyang/leetcode 如果各位看 阅读全文
posted @ 2015-06-28 23:20 Grandyang 阅读(916197) 评论(155) 推荐(102) 编辑
摘要:We are given an array A of N lowercase letter strings, all of the same length. Now, we may choose any set of deletion indices, and for each string, we 阅读全文
posted @ 2020-08-07 15:28 Grandyang 阅读(65) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers A with even length, return true if and only if it is possible to reorder it such that A[2 * i + 1] = 2 * A[2 * i] for every 阅读全文
posted @ 2020-07-26 13:25 Grandyang 阅读(94) 评论(0) 推荐(0) 编辑
摘要:In an alien language, surprisingly they also use english lowercase letters, but possibly in a different order. The order of the alphabet is some permu 阅读全文
posted @ 2020-07-08 15:47 Grandyang 阅读(199) 评论(0) 推荐(0) 编辑
摘要:Given a non-empty array of unique positive integers A, consider the following graph: There are A.length nodes, labelled A[0] to A[A.length - 1]; There 阅读全文
posted @ 2020-07-06 10:22 Grandyang 阅读(80) 评论(0) 推荐(0) 编辑
摘要:For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees. A binary tree X is flip e 阅读全文
posted @ 2020-07-02 15:00 Grandyang 阅读(135) 评论(0) 推荐(0) 编辑
摘要:In a deck of cards, every card has a unique integer. You can order the deck in any order you want. Initially, all the cards start face down (unreveale 阅读全文
posted @ 2020-06-22 11:51 Grandyang 阅读(128) 评论(0) 推荐(0) 编辑
摘要:Given an array of 4 digits, return the largest 24 hour time that can be made. The smallest 24 hour time is 00:00, and the largest is 23:59. Starting f 阅读全文
posted @ 2020-06-14 03:29 Grandyang 阅读(123) 评论(0) 推荐(0) 编辑
摘要:You have an initial power P, an initial score of 0 points, and a bag of tokens. Each token can be used at most once, has a value token[i], and has pot 阅读全文
posted @ 2020-06-11 13:06 Grandyang 阅读(118) 评论(0) 推荐(0) 编辑
摘要:On a 2D plane, we place stones at some integer coordinate points. Each coordinate point may have at most one stone. Now, a move consists of removing a 阅读全文
posted @ 2020-06-01 13:29 Grandyang 阅读(254) 评论(0) 推荐(0) 编辑
摘要:Given two sequences pushed and popped with distinct values, return true if and only if this could have been the result of a sequence of push and pop o 阅读全文
posted @ 2020-05-26 03:44 Grandyang 阅读(285) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers A, a move consists of choosing any , and incrementing it by . Return the least number of moves to make every value in uniqu 阅读全文
posted @ 2020-05-18 07:56 Grandyang 阅读(190) 评论(0) 推荐(0) 编辑
摘要:DynamoDB 是 AWS 全家桶中非常重要的一个服务,跟 MongoDB 一样,是 NoSQL 数据库。有时候我们需要将某个表的数据整个导出或者导入,如果数据量很大的话,建议 "使用 AWS Data Pipeline 导出和导入 DynamoDB" ,如果数据量不是特别大的话,建议使用 "AW 阅读全文
posted @ 2020-05-13 10:18 Grandyang 阅读(245) 评论(0) 推荐(0) 编辑
摘要:We are given an array of lowercase letter strings, all of the same length. Now, we may choose any set of deletion indices, and for each string, we del 阅读全文
posted @ 2020-05-11 06:16 Grandyang 阅读(161) 评论(0) 推荐(0) 编辑
摘要:Given an array A of strings, find any smallest string that contains each string in as a substring. We may assume that no string in is substring of ano 阅读全文
posted @ 2020-05-08 14:15 Grandyang 阅读(370) 评论(0) 推荐(0) 编辑
摘要:Given a string that only contains "I" (increase) or "D" (decrease), let . Return any permutation of such that for all : If , then Example 1: Example 2 阅读全文
posted @ 2020-04-30 04:33 Grandyang 阅读(158) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers, return if and only if it is a valid mountain array . Recall that A is a mountain array if and only if: There exists some w 阅读全文
posted @ 2020-04-27 07:19 Grandyang 阅读(221) 评论(0) 推荐(0) 编辑
摘要:Given a string , count the number of distinct, non empty subsequences of . Since the result may be large, return the answer modulo . Example 1: Exampl 阅读全文
posted @ 2020-04-20 06:23 Grandyang 阅读(2135) 评论(0) 推荐(0) 编辑
摘要:Given a set of points in the xy plane, determine the minimum area of a rectangle formed from these points, with sides parallel to the x and y axes. If 阅读全文
posted @ 2020-04-13 06:26 Grandyang 阅读(900) 评论(0) 推荐(0) 编辑
摘要:Given the node of a binary search tree, return the sum of values of all nodes with value between and (inclusive). The binary search tree is guaranteed 阅读全文
posted @ 2020-04-06 07:41 Grandyang 阅读(924) 评论(0) 推荐(0) 编辑
摘要:You have an array of . Each log is a space delimited string of words. For each log, the first word in each log is an alphanumeric identifier . Then, e 阅读全文
posted @ 2020-03-30 07:45 Grandyang 阅读(850) 评论(0) 推荐(0) 编辑
摘要:You want to form a string of lowercase letters. At the beginning, your sequence is `'?' stamp` of lowercase letters. On each turn, you may place the s 阅读全文
posted @ 2020-03-16 07:43 Grandyang 阅读(610) 评论(1) 推荐(1) 编辑
摘要:A chess knight can move as indicated in the chess diagram below: . This time, we place our chess knight on any numbered key of a phone pad (indicated 阅读全文
posted @ 2020-03-02 07:49 Grandyang 阅读(710) 评论(1) 推荐(0) 编辑
摘要:Write a class to count recent requests. It has only one method: , where t represents some time in milliseconds. Return the number of s that have been 阅读全文
posted @ 2020-02-25 00:59 Grandyang 阅读(549) 评论(0) 推荐(0) 编辑
摘要:When runs "serverless create_domain", we may get the following error: Could not find the certificate xxxx.com. at ServerlessCustomDomain. This indicat 阅读全文
posted @ 2020-02-20 14:49 Grandyang 阅读(219) 评论(0) 推荐(0) 编辑
摘要:In a given 2D binary array , there are two islands. (An island is a 4 directionally connected group of s not connected to any other 1s.) Now, we may c 阅读全文
posted @ 2020-02-19 23:28 Grandyang 阅读(863) 评论(0) 推荐(0) 编辑
摘要:For some fixed , an array is beautiful if it is a permutation of the integers , such that: For every `i 这道题定义了一种漂亮数组,说的是在任意两个数字之间,不存在一个正好是这两个数之和的一半的数字 阅读全文
posted @ 2020-02-09 14:47 Grandyang 阅读(823) 评论(0) 推荐(0) 编辑
摘要:Given a square array of integers , we want the minimum sum of a falling path through . A falling path starts at any element in the first row, and choo 阅读全文
posted @ 2020-02-06 14:44 Grandyang 阅读(564) 评论(0) 推荐(0) 编辑
摘要:In an array of s and s, how many non empty subarrays have sum ? Example 1: Note: 1. `A.length 这道题给了我们一个只由0和1组成的数组A,还有一个整数S,问数组A中有多少个子数组使得其和正好为S。博主最先没看 阅读全文
posted @ 2020-01-31 14:30 Grandyang 阅读(538) 评论(0) 推荐(0) 编辑
摘要:Every email consists of a local name and a domain name, separated by the @ sign. For example, in , is the local name, and is the domain name. Besides 阅读全文
posted @ 2020-01-27 04:39 Grandyang 阅读(587) 评论(0) 推荐(0) 编辑
摘要:(This problem is the same as Minimize Malware Spread , with the differences bolded.) In a network of nodes, each node is directly connected to another 阅读全文
posted @ 2020-01-22 14:10 Grandyang 阅读(515) 评论(0) 推荐(0) 编辑
摘要:Given an array of s and s, divide the array into 3 non empty parts such that all of these parts represent the same binary value. If it is possible, re 阅读全文
posted @ 2019-12-27 14:24 Grandyang 阅读(575) 评论(0) 推荐(0) 编辑
摘要:A string of s and s is monotone increasing if it consists of some number of s (possibly 0), followed by some number of s (also possibly 0.) We are giv 阅读全文
posted @ 2019-12-01 02:29 Grandyang 阅读(681) 评论(0) 推荐(0) 编辑
摘要:Your friend is typing his into a keyboard. Sometimes, when typing a character , the key might get long pressed , and the character will be typed 1 or 阅读全文
posted @ 2019-11-23 06:38 Grandyang 阅读(646) 评论(0) 推荐(0) 编辑
摘要:In a network of nodes, each node is directly connected to another node if and only if . Some nodes are initially infected by malware. Whenever two nod 阅读全文
posted @ 2019-11-11 22:05 Grandyang 阅读(994) 评论(0) 推荐(0) 编辑
摘要:Given an integer array , and an integer , return the number of tuples such that `i 这道题是之前那道 "3Sum" 的拓展,之前那道题是说没有重复数字,而这道题却有大量的重复数字,所以每个组合可能会大量重复出现,让我们 阅读全文
posted @ 2019-11-08 09:27 Grandyang 阅读(859) 评论(0) 推荐(0) 编辑
摘要:Given an array of non negative integers, half of the integers in A are odd, and half of the integers are even. Sort the array so that whenever is odd, 阅读全文
posted @ 2019-11-05 02:02 Grandyang 阅读(435) 评论(0) 推荐(0) 编辑
摘要:Given a string of and parentheses, we add the minimum number of parentheses ( or , and in any positions ) so that the resulting parentheses string is 阅读全文
posted @ 2019-10-31 04:28 Grandyang 阅读(545) 评论(0) 推荐(0) 编辑
摘要:Your music player contains different songs and she wants to listen to (not necessarily different) songs during your trip. You create a playlist so tha 阅读全文
posted @ 2019-10-25 23:54 Grandyang 阅读(591) 评论(2) 推荐(1) 编辑
摘要:A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possibl 阅读全文
posted @ 2019-10-23 23:55 Grandyang 阅读(4051) 评论(4) 推荐(0) 编辑
摘要:Given a circular array C of integers represented by , find the maximum possible sum of a non empty subarray of C. Here, a circular array means the end 阅读全文
posted @ 2019-10-21 21:26 Grandyang 阅读(2231) 评论(0) 推荐(0) 编辑
Fork me on GitHub