Fork me on GitHub
摘要:终于将LeetCode的大部分题刷完了,真是漫长的第一遍啊,估计很多题都忘的差不多了,这次开个题目汇总贴,并附上每道题目的解题连接,方便之后查阅吧~ 对应的 Github 项目的同步地址如下,欢迎大家关注点赞❤️ 如果各位看 阅读全文
posted @ 2015-06-28 23:20 Grandyang 阅读(1026740) 评论(155) 推荐(109) 编辑
摘要:We have a collection of stones, each stone has a positive integer weight. Each turn, we choose the two heaviest stones and smash them together. Suppos 阅读全文
posted @ 2021-03-01 12:31 Grandyang 阅读(3) 评论(0) 推荐(0) 编辑
摘要:Given an integer array , you should partition the array into (contiguous) subarrays of length at most . After partitioning, each subarray has their va 阅读全文
posted @ 2021-03-01 08:51 Grandyang 阅读(5) 评论(0) 推荐(0) 编辑
摘要:You have gardens, labeled from to , and an array where describes a bidirectional path between garden to garden . In each garden, you want to plant one 阅读全文
posted @ 2021-02-27 15:32 Grandyang 阅读(14) 评论(0) 推荐(0) 编辑
摘要:On an infinite plane, a robot initially stands at and faces north. The robot can receive one of three instructions: : go straight 1 unit; : turn 90 de 阅读全文
posted @ 2021-02-26 10:40 Grandyang 阅读(21) 评论(0) 推荐(0) 编辑
摘要:On an infinite number line, the position of the i th stone is given by . Call a stone an endpoint stone if it has the smallest or largest position. Ea 阅读全文
posted @ 2021-02-25 13:47 Grandyang 阅读(18) 评论(0) 推荐(0) 编辑
摘要:You have a convex n-sided polygon where each vertex has an integer value. You are given an integer array values where values[i] is the value of the it 阅读全文
posted @ 2021-02-22 08:23 Grandyang 阅读(16) 评论(0) 推荐(0) 编辑
摘要:Given the of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum 阅读全文
posted @ 2021-02-21 16:17 Grandyang 阅读(20) 评论(0) 推荐(0) 编辑
摘要:In a 1 million by 1 million grid, the coordinates of each grid square are . We start at the square and want to reach the square. Each move, we can wal 阅读全文
posted @ 2021-02-21 07:42 Grandyang 阅读(13) 评论(0) 推荐(0) 编辑
摘要:A boomerang is a set of 3 points that are all distinct and not in a straight line. Given a list of three points in the plane, return whether these poi 阅读全文
posted @ 2021-02-20 14:45 Grandyang 阅读(14) 评论(0) 推荐(0) 编辑
摘要:We write the integers of and (in the order they are given) on two separate horizontal lines. Now, we may draw connecting lines : a straight line conne 阅读全文
posted @ 2021-02-19 13:53 Grandyang 阅读(20) 评论(0) 推荐(0) 编辑
摘要:Given a 2 dimensional of integers, each value in the grid represents the color of the grid square at that location. Two squares belong to the same con 阅读全文
posted @ 2021-02-18 14:38 Grandyang 阅读(23) 评论(0) 推荐(0) 编辑
摘要:Three stones are on a number line at positions , , and . Each turn, you pick up a stone at an endpoint (ie., either the lowest or highest position sto 阅读全文
posted @ 2021-02-17 15:05 Grandyang 阅读(14) 评论(0) 推荐(0) 编辑
摘要:Implement the class as follows: : Constructor, init the data structure with the given words. : returns true if and only if for some , the last charact 阅读全文
posted @ 2021-02-16 13:27 Grandyang 阅读(19) 评论(0) 推荐(0) 编辑
摘要:Given an array of non negative integers, return the maximum sum of elements in two non overlapping (contiguous) subarrays, which have lengths and . (F 阅读全文
posted @ 2021-02-15 14:45 Grandyang 阅读(28) 评论(0) 推荐(0) 编辑
摘要:We are given a matrix with rows and columns has cells with integer coordinates , where `0 这道题给了一个R行C列的矩阵,又给了一个起始点 (r0, c0),让按照离起始点的曼哈顿距离从小到大排序坐标点。博主最先 阅读全文
posted @ 2021-02-14 13:41 Grandyang 阅读(345) 评论(0) 推荐(0) 编辑
摘要:A company is planning to interview people. Given the array where , the cost of flying the person to city is , and the cost of flying the person to cit 阅读全文
posted @ 2021-02-14 10:01 Grandyang 阅读(85) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers, return the length of the longest arithmetic subsequence in . Recall that a subsequence of is a list with `0 这道题给了一个数组,让找最长 阅读全文
posted @ 2021-02-13 11:10 Grandyang 阅读(53) 评论(0) 推荐(0) 编辑
摘要:Given the of a binary tree, find the maximum value for which there exist different nodes and where and is an ancestor of . A node is an ancestor of if 阅读全文
posted @ 2021-02-12 12:16 Grandyang 阅读(40) 评论(0) 推荐(0) 编辑
摘要:Alice and Bob take turns playing a game, with Alice starting first. Initially, there is a number on the chalkboard. On each player's turn, that player 阅读全文
posted @ 2021-02-11 14:31 Grandyang 阅读(59) 评论(0) 推荐(0) 编辑
摘要:You are given a series of video clips from a sporting event that lasted T seconds. These video clips can be overlapping with each other and have varie 阅读全文
posted @ 2021-02-10 14:44 Grandyang 阅读(100) 评论(0) 推荐(0) 编辑
摘要:A query word matches a given if we can insert lowercase letters to the pattern word so that it equals the . (We may insert each character at any posit 阅读全文
posted @ 2021-02-09 13:52 Grandyang 阅读(51) 评论(0) 推荐(0) 编辑
摘要:You are given the of a binary tree where each node has a value or . Each root to leaf path represents a binary number starting with the most significa 阅读全文
posted @ 2021-02-08 12:39 Grandyang 阅读(43) 评论(0) 推荐(0) 编辑
摘要:A valid parentheses string is either empty , , or , where and are valid parentheses strings, and represents string concatenation. For example, , , , a 阅读全文
posted @ 2021-02-08 02:19 Grandyang 阅读(39) 评论(0) 推荐(0) 编辑
摘要:Given a 2D array , each cell is 0 (representing sea) or 1 (representing land) A move consists of walking from one land square 4 directionally to anoth 阅读全文
posted @ 2021-02-07 15:19 Grandyang 阅读(42) 评论(0) 推荐(0) 编辑
摘要:We are given a linked list with as the first node. Let's number the nodes in the list: etc. Each node may have a next larger value: for , is the such 阅读全文
posted @ 2021-02-07 03:53 Grandyang 阅读(37) 评论(0) 推荐(0) 编辑
摘要:Given an array of s and s, consider : the i th subarray from to interpreted as a binary number (from most significant bit to least significant bit.) R 阅读全文
posted @ 2021-02-06 12:59 Grandyang 阅读(35) 评论(0) 推荐(0) 编辑
摘要:Given a number , return a string consisting of s and s that represents its value in base (negative two). The returned string must have no leading zero 阅读全文
posted @ 2021-02-05 14:25 Grandyang 阅读(52) 评论(0) 推荐(0) 编辑
摘要:Given a binary string (a string consisting only of '0' and '1's) and a positive integer , return true if and only if for every integer X from 1 to N, 阅读全文
posted @ 2021-02-04 14:08 Grandyang 阅读(49) 评论(0) 推荐(0) 编辑
摘要:Given a positive integer , you need to find the length of the smallest positive integer such that is divisible by , and only contains the digit . Retu 阅读全文
posted @ 2021-02-03 16:48 Grandyang 阅读(45) 评论(3) 推荐(0) 编辑
摘要:Given an array of positive integers, represents the value of the th sightseeing spot, and two sightseeing spots and have distance between them. The sc 阅读全文
posted @ 2021-02-02 13:32 Grandyang 阅读(50) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers , return if we can partition the array into three non empty parts with equal sums. Formally, we can partition the array if 阅读全文
posted @ 2021-02-01 15:37 Grandyang 阅读(30) 评论(0) 推荐(0) 编辑
摘要:Given a positive integer , return the number of positive integers less than or equal to that have at least 1 repeated digit. Example 1: Input: 20 Outp 阅读全文
posted @ 2021-01-31 16:48 Grandyang 阅读(43) 评论(0) 推荐(0) 编辑
摘要:A conveyor belt has packages that must be shipped from one port to another within D days. The ith package on the conveyor belt has a weight of weights 阅读全文
posted @ 2021-01-30 10:18 Grandyang 阅读(62) 评论(0) 推荐(0) 编辑
摘要:You are given a list of songs where the ith song has a duration of seconds. Return the number of pairs of songs for which their total duration in seco 阅读全文
posted @ 2021-01-29 12:55 Grandyang 阅读(54) 评论(0) 推荐(0) 编辑
摘要:Every non negative integer has a binary representation. For example, can be represented as in binary, as in binary, and so on. Note that except for , 阅读全文
posted @ 2021-01-25 06:24 Grandyang 阅读(50) 评论(0) 推荐(0) 编辑
摘要:Return the root node of a binary search tree that matches the given traversal. (Recall that a binary search tree is a binary tree where for every node 阅读全文
posted @ 2021-01-24 04:25 Grandyang 阅读(63) 评论(0) 推荐(0) 编辑
摘要:In a row of dominoes, and represent the top and bottom halves of the domino. (A domino is a tile with two numbers from 1 to 6 one on each half of the 阅读全文
posted @ 2021-01-20 15:20 Grandyang 阅读(69) 评论(0) 推荐(0) 编辑
摘要:Normally, the factorial of a positive integer is the product of all positive integers less than or equal to . For example, . We instead make a clumsy 阅读全文
posted @ 2021-01-19 10:08 Grandyang 阅读(64) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers, we must modify the array in the following way: we choose an and replace with , and we repeat this process times in total. 阅读全文
posted @ 2021-01-18 08:31 Grandyang 阅读(582) 评论(0) 推荐(0) 编辑
摘要:Given an array of 0s and 1s, we may change up to values from 0 to 1. Return the length of the longest (contiguous) subarray that contains only 1s. Exa 阅读全文
posted @ 2021-01-18 06:08 Grandyang 阅读(216) 评论(0) 推荐(0) 编辑
Fork me on GitHub