摘要: 终于将LeetCode的大部分题刷完了,真是漫长的第一遍啊,估计很多题都忘的差不多了,这次开个题目汇总贴,并附上每道题目的解题连接,方便之后查阅吧~ 对应的 Github 项目的同步地址如下,欢迎大家关注点赞❤️ https://github.com/grandyang/leetcode 如果各位看阅读全文
posted @ 2015-06-28 23:20 Grandyang 阅读(563653) 评论(143) 编辑
摘要: Write a class which collects daily price quotes for some stock, and returns the span of that stock's price for the current day. The span of the stock'阅读全文
posted @ 2019-06-15 23:27 Grandyang 阅读(11) 评论(0) 编辑
摘要: Given an array of integers , consider all non empty subsequences of . For any sequence S, let the width of S be the difference between the maximum and阅读全文
posted @ 2019-06-13 23:02 Grandyang 阅读(31) 评论(0) 编辑
摘要: Write an iterator that iterates through a run length encoded sequence. The iterator is initialized by , where is a run length encoding of some sequenc阅读全文
posted @ 2019-06-11 22:47 Grandyang 阅读(35) 评论(0) 编辑
摘要: A string of lowercase letters is given. Then, we may make any number of moves . In each move, we choose one of the first letters (starting from the le阅读全文
posted @ 2019-06-09 23:40 Grandyang 阅读(44) 评论(0) 编辑
摘要: Implement , a class which simulates the operation of a stack like data structure. has two functions: , which pushes an integer onto the stack. , which阅读全文
posted @ 2019-06-07 22:34 Grandyang 阅读(61) 评论(0) 编辑
摘要: We have an array of non negative integers. For every (contiguous) subarray (with `i 这是一道蛮有意思的题目,说是给了我们一个数组,里面都是非负数,问我们所有连续的子数组'或'起来能产生多少个不同的值。虽说这只是一道 阅读全文
posted @ 2019-06-05 23:15 Grandyang 阅读(70) 评论(0) 编辑
摘要: Given a tree, rearrange the tree in in order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and o阅读全文
posted @ 2019-06-03 22:40 Grandyang 阅读(67) 评论(0) 编辑
摘要: An array is monotonic if it is either monotone increasing or monotone decreasing. An array is monotone increasing if for all . Return if and only if t阅读全文
posted @ 2019-06-01 23:54 Grandyang 阅读(63) 评论(0) 编辑
摘要: A full binary tree is a binary tree where each node has exactly 0 or 2 children. Return a list of all possible full binary trees with nodes. Each elem阅读全文
posted @ 2019-05-30 22:34 Grandyang 阅读(79) 评论(0) 编辑
摘要: You are given an array of strings. Two strings and are special equivalent if after any number of moves , S == T. A move consists of choosing two indic阅读全文
posted @ 2019-05-28 23:25 Grandyang 阅读(71) 评论(0) 编辑
摘要: On a grid, we place some cubes. Each value represents a tower of cubes placed on top of grid cell . Return the total surface area of the resulting sha阅读全文
posted @ 2019-05-26 23:28 Grandyang 阅读(80) 评论(0) 编辑
摘要: You have a list of and a , and you want to know which words in matches the pattern. A word matches the pattern if there exists a permutation of letter阅读全文
posted @ 2019-05-24 22:06 Grandyang 阅读(81) 评论(0) 编辑
摘要: Return any binary tree that matches the given preorder and postorder traversals. Values in the traversals and are distinct positive integers. Example 阅读全文
posted @ 2019-05-22 23:10 Grandyang 阅读(127) 评论(2) 编辑
摘要: Alice and Bob have candy bars of different sizes: is the size of the th bar of candy that Alice has, and is the size of the th bar of candy that Bob h阅读全文
posted @ 2019-05-20 19:45 Grandyang 阅读(132) 评论(0) 编辑
摘要: On a 2 dimensional grid with rows and columns, we start at facing east. Here, the north west corner of the grid is at the first row and column, and th阅读全文
posted @ 2019-05-18 23:04 Grandyang 阅读(101) 评论(0) 编辑
摘要: We are given two sentences and . (A sentence is a string of space separated words. Each word consists only of lowercase letters.) A word is uncommon i阅读全文
posted @ 2019-05-16 20:42 Grandyang 阅读(94) 评论(0) 编辑
摘要: On a grid, we place some cubes that are axis aligned with the x, y, and z axes. Each value represents a tower of cubes placed on top of grid cell . No阅读全文
posted @ 2019-05-15 00:06 Grandyang 阅读(97) 评论(0) 编辑
摘要: The th person has weight , and each boat can carry a maximum weight of . Each boat carries at most 2 people at the same time, provided the sum of the 阅读全文
posted @ 2019-05-12 23:48 Grandyang 阅读(160) 评论(0) 编辑
摘要: An encoded string is given. To find and write the decoded string to a tape, the encoded string is read one character at a time and the following steps阅读全文
posted @ 2019-05-10 23:20 Grandyang 阅读(1487) 评论(0) 编辑
摘要: 引言 为什么想到制作这么一个插件呢,是因为博主在更新微信公众号【刷尽天下】的后台数据库时,需要有博客园题目帖子的链接,那么就要从这篇帖子 "LeetCode All in One 题目讲解汇总(持续更新中...)" 中提取各个题目的链接。之前博主都是使用的都是Excel的插件 "Kutools" 来阅读全文
posted @ 2019-05-09 10:06 Grandyang 阅读(132) 评论(0) 编辑
摘要: Alex and Lee play a game with piles of stones. There are an even number of piles arranged in a row, and each pile has a positive integer number of sto阅读全文
posted @ 2019-05-07 22:44 Grandyang 阅读(552) 评论(0) 编辑
摘要: Given a non empty, singly linked list with head node , return a middle node of linked list. If there are two middle nodes, return the second middle no阅读全文
posted @ 2019-05-06 01:00 Grandyang 阅读(412) 评论(0) 编辑
摘要: Koko loves to eat bananas. There are piles of bananas, the th pile has bananas. The guards have gone and will come back in hours. Koko can decide her 阅读全文
posted @ 2019-05-03 23:43 Grandyang 阅读(338) 评论(0) 编辑
摘要: A robot on an infinite grid starts at point (0, 0) and faces north. The robot can receive one of three possible types of commands: : turn left 90 degr阅读全文
posted @ 2019-05-01 22:17 Grandyang 阅读(346) 评论(0) 编辑
摘要: In an array containing only 0s and 1s, a bit flip consists of choosing a (contiguous) subarray of length and simultaneously changing every 0 in the su阅读全文
posted @ 2019-04-29 23:48 Grandyang 阅读(122) 评论(0) 编辑
摘要: A sequence is fibonacci like if: for all `i + 2 这道题给了我们一个数组,让找其中最长的斐波那契序列,既然是序列而非子数组,那么数字就不必挨着,但是顺序还是需要保持,题目中说了数组是严格递增的,其实博主认为这个条件可有可无的,反正又不能用二分搜索。关于斐阅读全文
posted @ 2019-04-27 23:59 Grandyang 阅读(301) 评论(0) 编辑
摘要: Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequence. For example, in the given t阅读全文
posted @ 2019-04-25 23:27 Grandyang 阅读(261) 评论(0) 编辑
摘要: Given two arrays and of equal size, the advantage of with respect to is the number of indices for which . Return any permutation of that maximizes its阅读全文
posted @ 2019-04-23 22:36 Grandyang 阅读(247) 评论(0) 编辑
摘要: Starting with a positive integer , we reorder the digits in any order (including the original order) such that the leading digit is not zero. Return i阅读全文
posted @ 2019-04-21 23:57 Grandyang 阅读(190) 评论(0) 编辑
摘要: Given a positive integer , find and return the longest distance between two consecutive 1's in the binary representation of . If there aren't two cons阅读全文
posted @ 2019-04-19 22:52 Grandyang 阅读(223) 评论(0) 编辑
摘要: Given a matrix , return the transpose of . The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indic阅读全文
posted @ 2019-04-17 23:29 Grandyang 阅读(244) 评论(0) 编辑
摘要: Find the smallest prime palindrome greater than or equal to . Recall that a number is prime if it's only divisors are 1 and itself, and it is greater 阅读全文
posted @ 2019-04-15 23:04 Grandyang 阅读(231) 评论(0) 编辑
摘要: Given a binary tree rooted at , the depth of each node is the shortest distance to the root. A node is deepest if it has the largest depth possible am阅读全文
posted @ 2019-04-13 23:53 Grandyang 阅读(230) 评论(0) 编辑
摘要: We are given a binary tree (with root node ), a node, and an integer value . Return a list of the values of all nodes that have a distance from the no阅读全文
posted @ 2019-04-10 23:18 Grandyang 阅读(442) 评论(0) 编辑
摘要: We have a two dimensional matrix where each value is or . A move consists of choosing any row or column, and toggling each value in that row or column阅读全文
posted @ 2019-04-08 23:55 Grandyang 阅读(215) 评论(0) 编辑
摘要: At a lemonade stand, each lemonade costs . Customers are standing in a queue to buy from you, and order one at a time (in the order specified by ). Ea阅读全文
posted @ 2019-04-06 23:45 Grandyang 阅读(278) 评论(0) 编辑
摘要: Given two strings and of lowercase letters, return if and only if we can swap two letters in so that the result equals . Example 1: Example 2: Example阅读全文
posted @ 2019-04-04 23:33 Grandyang 阅读(280) 评论(0) 编辑
摘要: There is a special square room with mirrors on each of the four walls. Except for the southwest corner, there are receptors on each of the remaining c阅读全文
posted @ 2019-04-02 22:56 Grandyang 阅读(294) 评论(0) 编辑
摘要: Given a balanced parentheses string , compute the score of the string based on the following rule: has score 1 has score , where A and B are balanced 阅读全文
posted @ 2019-03-31 23:55 Grandyang 阅读(257) 评论(0) 编辑
摘要: In an exam room, there are seats in a single row, numbered . When a student enters the room, they must sit in the seat that maximizes the distance to 阅读全文
posted @ 2019-03-28 22:59 Grandyang 阅读(439) 评论(0) 编辑