
LeetCode
文章平均质量分 52
LawFile
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
#1477. Find Two Non-overlapping Sub-arrays Each With Target Sum
题目描述:Given an array of integersarrand an integertarget.You have to findtwo non-overlapping sub-arraysofarreach with sum equaltarget. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays ...原创 2020-07-27 11:46:51 · 379 阅读 · 0 评论 -
#1423. Maximum Points You Can Obtain from Cards
题目描述:There are several cardsarranged in a row, and each card has an associated number of pointsThe points are given in the integer arraycardPoints.In one step, you can take one card from the beginning or from the end of the row. You have to take exa...原创 2020-07-27 11:45:36 · 303 阅读 · 0 评论 -
#752. Open the Lock
题目描述:You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots:'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'. The wheels can rotate freely and wrap around: for example we can turn'9'to be'0', or'0'to be'9'. Each move consi...原创 2020-07-27 11:44:24 · 317 阅读 · 0 评论 -
#1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit
题目描述:Given anarray of integersnumsand anintegerlimit, return the size of the longestnon-emptysubarray such that the absolute difference between any two elements of this subarray is less than or equal tolimit.Example 1:Input: nums = [8,2,4,7]...原创 2020-07-27 11:42:50 · 264 阅读 · 0 评论 -
#946. Validate Stack Sequences
题目描述:Given two sequencespushedandpoppedwith distinct values,returntrueif and only if this could have been the result of a sequence of push and pop operations on an initially empty stack.Example 1:Input: pushed = [1,2,3,4,5], popped = [4,5,3,2...原创 2020-07-27 11:41:27 · 168 阅读 · 0 评论 -
LeetCode #464. Can I Win
题目描述:In the "100 game," two players take turns adding, to a running total, any integer from 1..10. The player who first causes the running total to reach or exceed 100 wins.What if we change the g...原创 2019-12-02 07:24:43 · 166 阅读 · 0 评论 -
LeetCode #456. 132 Pattern
题目描述:Given a sequence of n integers a1, a2, ..., an, a 132 pattern is a subsequence ai, aj, aksuch thati<j<kand ai< ak< aj. Design an algorithm that takes a list of n numbers as...原创 2019-12-02 07:24:54 · 166 阅读 · 0 评论 -
LeetCode #508. Most Frequent Subtree Sum
题目描述:Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a node is defined as the sum of all the node values formed by the subtree rooted at that node (...原创 2019-12-02 07:24:59 · 182 阅读 · 0 评论 -
LeetCode #509. Fibonacci Number
题目描述:TheFibonacci numbers, commonly denotedF(n)form a sequence, called theFibonacci sequence, such that each number is the sum of the two preceding ones, starting from0and1. That is,F(0) =...原创 2019-11-29 11:24:32 · 220 阅读 · 0 评论 -
LeetCode #433. Minimum Genetic Mutation
题目描述:A gene string can be represented by an 8-character long string, with choices from"A","C","G","T".Suppose we need to investigate about a mutation (mutation from "start" to "end"), where ON...原创 2019-11-29 11:20:04 · 199 阅读 · 0 评论 -
LeetCode #422. Valid Word Square
题目描述:Given a sequence of words, check whether it forms a valid word square.A sequence of words forms a valid word square if thekthrow and column read the exact same string, where 0 ≤k< max(...原创 2019-11-29 11:07:00 · 212 阅读 · 0 评论 -
LeetCode #408. Valid Word Abbreviation
题目描述:Given anon-emptystringsand an abbreviationabbr, return whether the string matches with the given abbreviation.A string such as"word"contains only the following valid abbreviations:[...原创 2019-11-29 10:46:29 · 224 阅读 · 0 评论 -
LeetCode #382. Linked List Random Node
题目描述:Given a singly linked list, return a random node's value from the linked list. Each node must have thesame probabilityof being chosen.Follow up:What if the linked list is extremely large a...原创 2019-11-29 10:28:33 · 151 阅读 · 0 评论 -
LeetCode #379. Design Phone Directory
题目描述:Design a Phone Directory which supports the following operations:get: Provide a number which is not assigned to anyone. check: Check if a number is available or not. release: Recycle or rel...原创 2019-11-29 10:22:02 · 219 阅读 · 0 评论 -
LeetCode #294. Flip Game II
题目描述:You are playing the following Flip Game with your friend: Given a string that contains only these two characters:+and-, you and your friend take turns to flip twoconsecutive"++"into"--"....原创 2019-11-29 10:04:26 · 152 阅读 · 0 评论 -
LeetCode #293. Flip Game
题目描述:You are playing the following Flip Game with your friend: Given a string that contains only these two characters:+and-, you and your friend take turns to flip twoconsecutive"++"into"--"....原创 2019-11-29 09:56:08 · 166 阅读 · 0 评论 -
LeetCode #288. Unique Word Abbreviation
题目描述:An abbreviation of a word follows the form <first letter><number><last letter>. Below are some examples of word abbreviations:a) it --> it (no ab...原创 2019-11-29 09:50:04 · 219 阅读 · 0 评论 -
LeetCode #281. Zigzag Iterator
题目描述:Given two 1d vectors, implement an iterator to return their elements alternately.Example:Input: v1 = [1,2] v2 = [3,4,5,6] Output: [1,3,2,4,5,6]Explanation:By calling next repeatedly un...原创 2019-11-29 09:23:18 · 238 阅读 · 0 评论 -
LeetCode #276. Paint Fence
题目描述:There is a fence with n posts, each post can be painted with one of the k colors.You have to paint all the posts such that no more than two adjacent fence posts have the same color.Return t...原创 2019-11-28 09:49:52 · 173 阅读 · 0 评论 -
LeetCode #266. Palindrome Permutation
题目描述:Given a string, determine if a permutation of the string could form a palindrome.Example 1:Input: "code"Output: falseExample 2:Input: "aab"Output: trueExample 3:Input: "carer...原创 2019-11-28 09:16:51 · 167 阅读 · 0 评论 -
LeetCode #261. Graph Valid Tree
题目描述:Givennnodes labeled from0ton-1and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges make up a valid tree.Example 1:Input: n = ...原创 2019-11-28 09:14:08 · 216 阅读 · 0 评论 -
LeetCode #225. Implement Stack using Queues
题目描述:Implement the following operations of a stack using queues.push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top() -- Get the top element. empty() -- ...原创 2019-11-28 08:45:34 · 180 阅读 · 0 评论 -
LeetCode #938. Range Sum of BST
题目描述:Given therootnode of a binary search tree, return the sum of values of all nodes with value betweenLandR(inclusive).The binary search tree is guaranteed to have unique values.Example ...原创 2019-11-28 08:35:30 · 132 阅读 · 0 评论 -
LeetCode #895. Maximum Frequency Stack
题目描述:ImplementFreqStack, a class which simulates the operation of a stack-like data structure.FreqStackhas two functions:push(int x), which pushes an integerxonto the stack. pop(), whichre...原创 2019-11-27 09:48:25 · 208 阅读 · 0 评论 -
LeetCode #861. Score After Flipping Matrix
题目描述:We have a two dimensional matrixAwhere each value is0or1.A move consists of choosing any row or column, and toggling each value in that row or column: changing all0s to1s, and all1s t...原创 2019-11-05 05:02:52 · 158 阅读 · 0 评论 -
LeetCode #589. N-ary Tree Preorder Traversal
题目描述:Given an n-ary tree, return thepreordertraversal of its nodes' values.For example, given a3-arytree:Return its preorder traversal as:[1,3,5,6,2,4].class Solution {public: vec...原创 2019-11-04 04:04:09 · 132 阅读 · 0 评论 -
LeetCode #429. N-ary Tree Level Order Traversal
题目描述:Given an n-ary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example, given a3-arytree:We should return its level order trave...原创 2019-11-04 03:36:50 · 140 阅读 · 0 评论 -
LeetCode #156. Binary Tree Upside Down
题目描述:Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty, flip it upside down and turn it into a tree where the...原创 2019-11-02 11:13:58 · 159 阅读 · 0 评论 -
LeetCode #590. N-ary Tree Postorder Traversal
题目描述:Given an n-ary tree, return thepostordertraversal of its nodes' values.For example, given a3-arytree:Return its postorder traversal as:[5,6,3,2,4,1].class Solution {public: v...原创 2019-10-31 05:11:03 · 262 阅读 · 0 评论 -
LeetCode #1219. Path with Maximum Gold
题目描述:In a gold minegridof sizem * n,each cell in this mine has an integer representing the amount of goldin that cell,0if it is empty.Return the maximum amount of gold youcan collect under...原创 2019-10-29 11:49:55 · 240 阅读 · 0 评论 -
LeetCode #1143. Longest Common Subsequence
题目描述:Given two stringstext1andtext2, return the length of their longest common subsequence.Asubsequenceof a string is a new string generated from the original string with some characters(can ...原创 2019-10-29 11:31:46 · 151 阅读 · 0 评论 -
LeetCode #1074. Number of Submatrices That Sum to Target
题目描述:Given amatrix, and atarget, return the number of non-empty submatrices that sum totarget.A submatrixx1, y1, x2, y2is the set of all cellsmatrix[x][y]withx1 <= x <= x2andy1 <...原创 2019-10-29 08:25:23 · 207 阅读 · 0 评论 -
LeetCode #802. Find Eventual Safe States
题目描述:In a directed graph, we start at some node and every turn, walk along a directed edge of the graph. If we reach a node that is terminal (that is, it has no outgoing directed edges), we stop....原创 2019-10-29 08:10:38 · 158 阅读 · 0 评论 -
LeetCode #855. Exam Room
题目描述:In an exam room, there areNseats in a single row, numbered0, 1, 2, ..., N-1.When a student enters the room, they must sit in the seat that maximizes the distance to the closest person. If...原创 2019-10-29 06:05:21 · 221 阅读 · 0 评论 -
LeetCode #1047. Remove All Adjacent Duplicates In String
题目描述:Given a stringSof lowercase letters, aduplicate removalconsists of choosing two adjacent and equal letters, and removingthem.We repeatedly make duplicate removals on S until we no longer...原创 2019-10-29 04:52:44 · 129 阅读 · 0 评论 -
LeetCode #1096. Brace Expansion II
题目描述:Under a grammar given below, strings can represent a set of lowercase words. Let'suseR(expr)to denote thesetof words the expression represents.Grammar can best be understood through sim...原创 2019-10-29 04:42:51 · 424 阅读 · 0 评论 -
LeetCode #360. Sort Transformed Array
题目描述:Given asortedarray of integersnumsand integer valuesa,bandc. Apply a quadratic function of the form f(x) =ax2+bx+cto each elementxin the array.The returned array must be inso...原创 2019-10-29 03:24:38 · 202 阅读 · 0 评论 -
LeetCode #369. Plus One Linked List
题目描述:Given a non-negative integer represented asnon-emptya singly linked list of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 i...原创 2019-10-28 23:20:59 · 223 阅读 · 0 评论 -
LeetCode #174. Dungeon Game
题目描述:The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initia...原创 2019-10-25 12:00:54 · 143 阅读 · 0 评论 -
LeetCode #1231. Divide Chocolate
题目描述:You have one chocolate bar that consists of some chunks. Each chunk has its own sweetness given by the arraysweetness.You want to share the chocolate with yourKfriends so you start cutting...原创 2019-10-24 22:13:40 · 1028 阅读 · 0 评论