Fork me on GitHub
摘要:终于将LeetCode的大部分题刷完了,真是漫长的第一遍啊,估计很多题都忘的差不多了,这次开个题目汇总贴,并附上每道题目的解题连接,方便之后查阅吧~ 对应的 Github 项目的同步地址如下,欢迎大家关注点赞❤️ https://github.com/grandyang/leetcode 如果各位看 阅读全文
posted @ 2015-06-28 23:20 Grandyang 阅读(964816) 评论(155) 推荐(103) 编辑
摘要:Given a binary tree, determine if it is a complete binary tree. Definition of a complete binary tree from Wikipedia: In a complete binary tree every l 阅读全文
posted @ 2020-09-21 20:30 Grandyang 阅读(229) 评论(0) 推荐(0) 编辑
摘要:There are 8 prison cells in a row, and each cell is either occupied or vacant. Each day, whether the cell is occupied or vacant changes according to t 阅读全文
posted @ 2020-08-31 12:28 Grandyang 阅读(309) 评论(0) 推荐(0) 编辑
摘要:You are installing a billboard and want it to have the largest height. The billboard will have two steel supports, one on each side. Each steel suppor 阅读全文
posted @ 2020-08-17 21:51 Grandyang 阅读(214) 评论(0) 推荐(0) 编辑
摘要: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 23:28 Grandyang 阅读(259) 评论(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 21:25 Grandyang 阅读(225) 评论(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 23:47 Grandyang 阅读(542) 评论(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 18:22 Grandyang 阅读(720) 评论(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 23:00 Grandyang 阅读(304) 评论(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 19:51 Grandyang 阅读(253) 评论(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 11:29 Grandyang 阅读(701) 评论(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 21:06 Grandyang 阅读(429) 评论(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 21:29 Grandyang 阅读(441) 评论(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 11:44 Grandyang 阅读(479) 评论(0) 推荐(1) 编辑
摘要: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 15:56 Grandyang 阅读(296) 评论(0) 推荐(0) 编辑
摘要:DynamoDB 是 AWS 全家桶中非常重要的一个服务,跟 MongoDB 一样,是 NoSQL 数据库。有时候我们需要将某个表的数据整个导出或者导入,如果数据量很大的话,建议 "使用 AWS Data Pipeline 导出和导入 DynamoDB" ,如果数据量不是特别大的话,建议使用 "AW 阅读全文
posted @ 2020-05-13 18:18 Grandyang 阅读(346) 评论(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 14:16 Grandyang 阅读(268) 评论(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 22:15 Grandyang 阅读(504) 评论(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 12:33 Grandyang 阅读(230) 评论(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 15:19 Grandyang 阅读(311) 评论(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 14:23 Grandyang 阅读(3198) 评论(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 14:26 Grandyang 阅读(1384) 评论(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 15:41 Grandyang 阅读(1417) 评论(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 15:45 Grandyang 阅读(1291) 评论(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 15:43 Grandyang 阅读(869) 评论(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 15:49 Grandyang 阅读(1019) 评论(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 08:59 Grandyang 阅读(1041) 评论(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 22:49 Grandyang 阅读(267) 评论(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-20 07:28 Grandyang 阅读(1277) 评论(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 22:47 Grandyang 阅读(1166) 评论(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 22:44 Grandyang 阅读(769) 评论(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 22:30 Grandyang 阅读(779) 评论(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 12:39 Grandyang 阅读(768) 评论(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 22:10 Grandyang 阅读(683) 评论(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 22:24 Grandyang 阅读(776) 评论(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 10:29 Grandyang 阅读(880) 评论(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 14:38 Grandyang 阅读(867) 评论(1) 推荐(1) 编辑
摘要: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-12 06:05 Grandyang 阅读(1208) 评论(0) 推荐(0) 编辑
摘要:Given an integer array , and an integer , return the number of tuples such that `i 这道题是之前那道 "3Sum" 的拓展,之前那道题是说没有重复数字,而这道题却有大量的重复数字,所以每个组合可能会大量重复出现,让我们 阅读全文
posted @ 2019-11-08 17:27 Grandyang 阅读(1124) 评论(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 10:02 Grandyang 阅读(631) 评论(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 12:28 Grandyang 阅读(741) 评论(0) 推荐(0) 编辑
Fork me on GitHub