- 博客(627)
- 收藏
- 关注
原创 #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 330
原创 #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 251
原创 #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 269
原创 #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 219
原创 #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 138
原创 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 154
原创 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 125
原创 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 141
原创 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 181
原创 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 165
原创 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 171
原创 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 193
原创 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 123
原创 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 170
原创 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 120
原创 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 128
原创 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 181
原创 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 197
原创 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 147
原创 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 132
原创 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 189
原创 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 152
原创 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 103
原创 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 162
原创 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 130
原创 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 101
原创 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 113
原创 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 122
原创 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 233
原创 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 208
原创 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 121
原创 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 165
原创 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 125
原创 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 172
原创 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 102
原创 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 388
原创 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 162
原创 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 192
原创 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 115
原创 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 978
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人