- 博客(240)
- 收藏
- 关注
转载 [LeetCode 1171] Remove Zero Sum Consecutive Nodes from Linked List
Given theheadof a linked list, we repeatedly delete consecutive sequences of nodes that sum to0until there are no such sequences.After doing so, return the head of the final linked list. Y...
2019-09-29 07:04:00
252
转载 [LeetCode 560] Subarray Sum Equals K
Given an array of integers and an integerk, you need to find the total number of continuous subarrays whose sum equals tok.Example 1:Input:nums = [1,1,1], k = 2Output: 2Note:Th...
2019-09-29 06:26:00
234
转载 Line of wines
There are N wines in a row. Each year you sell either the leftmost or the rightmost wine. The i-th wine has initial price p[i] and price k * p[i] in the k-th year. What is the maximum possible to...
2019-09-27 00:23:00
243
转载 [LeetCode 1197] Minimum Knight Moves
In aninfinitechess board with coordinates from-infinityto+infinity, you have aknightat square[0, 0].Aknight has 8 possible moves it can make, as illustrated below. Each move is two squ...
2019-09-22 01:23:00
646
转载 [Daily Coding Problem 293] Minimum Cost to Construct Pyramid with Stones
You haveNstones in a row, and would like to create from them a pyramid. This pyramid should be constructed such that the height of each stone increases by one until reaching the tallest stone, ...
2019-09-20 05:46:00
158
转载 [Daily Coding Problem 294] Shortest round route with rising then falling elevations
A competitive runner would like to create a route that starts and ends at his house, with the condition that the route goes entirely uphill at first, and then entirely downhill.Given a dictiona...
2019-09-19 11:38:00
160
转载 [LeetCode 1186] Maximum Subarray Sum with One Deletion
Given an array of integers, return the maximum sum for anon-emptysubarray (contiguous elements) with at most one element deletion.In other words, you want to choose a subarray and optionally d...
2019-09-16 23:31:00
246
转载 [Daily Coding Problem 290] Quxes Transformation
On a mysterious island there are creatures known as Quxes which come in three colors: red, green, and blue. One power of the Qux is that if two of them are standing next to each other, they can t...
2019-09-14 03:21:00
144
转载 [LeetCode 1177] Can Make Palindrome from Substring
Given a strings, we make queries on substrings ofs.For each queryqueries[i] = [left, right, k], we mayrearrangethe substrings[left], ..., s[right], and then chooseup tokof them to repl...
2019-09-04 23:28:00
176
转载 [LeetCode 322] Coin Change
You are given coins of different denominations and a total amount of moneyamount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of m...
2019-08-30 06:46:00
96
转载 [LeetCode 1146] Snapshot Array
mplement a SnapshotArray that supports the following interface:SnapshotArray(int length)initializes an array-like data structure with the given length.Initially, each element equals 0.vo...
2019-08-07 12:06:00
153
转载 [Daily Coding Problem 250] Cryptarithmetic Puzzle
A cryptarithmetic puzzle is a mathematical game where the digits of some numbers are represented by letters. Each letter represents a unique digit.For example, a puzzle of the form: SEND+ ...
2019-08-06 10:17:00
258
转载 [LeetCode 1136] Parallel Courses
There areNcourses, labelled from 1 toN.We are givenrelations[i] = [X, Y], representing a prerequisite relationship between courseXand courseY:courseXhas to be studied before courseY....
2019-08-01 10:15:00
297
转载 [LeetCode 1121] Divide Array Into Increasing Sequences
Given anon-decreasingarray of positive integersnumsand an integerK, find out if this array can be divided into one or moredisjoint increasing subsequences of length at leastK.Example ...
2019-07-15 22:11:00
142
转载 [Daily Coding Problem 223] O(1) space in order traversal of a binary tree
Typically, an implementation of in-order traversal of a binary tree hasO(h)space complexity, wherehis the height of the tree. Write a program to compute the in-order traversal of a binary tre...
2019-07-10 22:40:00
194
转载 [Daily Coding Problem 224] Find smallest positive integer that is not the sum of a subset of a sorte...
Given a sorted array of non-negative integers, find the smallest positive integer that is not the sum of a subset of the array.For example, for the input[1, 2, 3, 10], you should return7.Do...
2019-07-10 11:43:00
184
转载 Sliding Window Algorithm Questions
LeetCode424.Longest Repeating Character ReplacementGiven a string that consists of only uppercase English letters, you can replace any letter in the string with another letter at mostktimes...
2019-04-13 03:48:00
119
转载 Sweep Line Algorithm Summary
Given a set of closed intervals, find the smallest set of numbers that covers all the intervals. If there are multiple smallest sets, return any of them.For example, given the intervals[0, 3],...
2019-03-30 01:42:00
495
转载 Palindrome Algorithm Questions
Given a string which we can delete at most k, return whether you can make a palindrome.For example, given 'waterrfetawx' and a k of 2, you could delete f and x to get 'waterretaw'.Notice t...
2019-03-29 12:31:00
111
转载 Core Data Structures, Algorithms and Concepts
Graph: n nodes, m edgesRepresentationAdjacency Matrix: O(n^2) space, not efficient for sparse graphAdjacency List: O(n + m) space, efficient for sparse graphTraversalBFS: Runtime: O...
2019-03-08 12:27:00
154
转载 [LeetCode] 1000. Minimum Cost to Merge Stones
There areNpiles of stones arranged in a row. Thei-th pile hasstones[i]stones.Amoveconsists of mergingexactlyKconsecutivepiles into one pile, and the cost of this move is equal to th...
2019-03-04 07:49:00
148
转载 [LeetCode] 1004. Max Consecutive Ones III
Given an arrayAof 0s and 1s, we may change up toKvalues from 0 to 1.Return the length of the longest (contiguous) subarray that contains only 1s.Example 1:Input: A = [1,1,1,0,0,0,...
2019-03-04 00:33:00
84
转载 [LeetCode] 1003. Check If Word Is Valid After Substitutions
We are given that the string"abc"is valid.From any valid stringV, we may splitVinto two piecesXandYsuch thatX + Y(Xconcatenated withY) is equal toV. (XorYmay be empty.) Then,...
2019-03-04 00:14:00
80
转载 [LeetCode] 82. Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.Example 1:Input: 1->2->3->3->4->4->5Output: ...
2019-03-02 13:20:00
57
转载 [LeetCode] 907. Sum of Subarray Minimums
Given an array of integersA, find the sum ofmin(B), whereBranges overevery (contiguous) subarray ofA.Since the answer may be large,return the answer modulo10^9 + 7.Example 1:Inpu...
2019-03-02 00:51:00
107
转载 [LeetCode] 1001. Grid Illumination
On aN x Ngrid of cells, each cell(x, y)with0 <= x < Nand0 <= y < Nhas a lamp.Initially, some number of lamps are on.lamps[i]tells us the location of thei-th lamp that is...
2019-02-26 12:38:00
72
转载 [LeetCode] 995. Minimum Number of K Consecutive Bit Flips
In an arrayAcontaining only 0s and 1s, aK-bit flipconsists of choosing a (contiguous) subarray of lengthKand simultaneously changing every 0 in the subarray to 1, and every 1 in the subarra...
2019-02-19 07:13:00
97
转载 [LeetCode] 872. Leaf-Similar Trees
Consider all the leaves of a binary tree. Fromleft to right order, the values of thoseleaves form aleaf value sequence.For example, in the given tree above, the leaf value sequence is...
2019-02-13 22:57:00
71
转载 [Daily Coding Problem 72] Max path value in directed graph
This problem was asked by Google.In a directed graph, each node is assigned an uppercase letter. We define a path's value as the number of most frequently-occurring letter along that path. For ...
2019-02-12 13:00:00
109
转载 [LeetCode 989] Add to Array-Form of Integer
For a non-negative integerX, thearray-form ofXis an array of its digits in left to right order. For example, ifX = 1231, then the array form is[1,2,3,1].Given the array-formAof a non-n...
2019-02-11 07:07:00
81
转载 [LeetCode 987] Vertical Order Traversal of a Binary Tree
Given a binary tree, return thevertical ordertraversal of its nodesvalues.For each node at position(X, Y), its left and right children respectivelywill be at positions(X-1, Y-1)and(X+1,...
2019-02-10 10:20:00
107
转载 [LeetCode 984] String Without AAA or BBB
Given two integersAandB, returnanystringSsuch that:Shas lengthA + Band contains exactlyA'a'letters, and exactlyB'b'letters;The substring'aaa'does not occur inS;The ...
2019-02-10 02:08:00
127
转载 [Daily Coding Problem 70] Nth perfect number
This problem was asked by Microsoft.A number is considered perfect if its digits sum up to exactly 10.Given a positive integern, return then-th perfect number.For example, given 1, you sh...
2019-02-06 01:14:00
114
转载 [LeetCode 988] Smallest String Starting From Leaf
Given therootof a binary tree, each node has a value from0to25representing the letters'a'to'z': a value of0represents'a', a value of1represents'b', and so on.Find the lexicograph...
2019-02-05 12:48:00
124
转载 [Daily Coding Problem 68] Count Pairs of attacking bishop pairs
Thisproblemwas asked by Google.On our special chessboard, two bishops attack each other if they share the same diagonal. This includes bishops that have another bishop located between them, i...
2019-02-05 02:51:00
98
转载 [LeetCode] 687. Longest Univalue Path
Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the root.Note:The length of path between two node...
2019-01-04 23:44:00
92
转载 [Daily Coding Problem] 1 (LeetCode 1). Find if two numbers in an array add up to k
Thisproblemwas recently asked by Google.Given a list of numbers and a numberk, return whether any two numbers from the list add up tok.For example, given[10, 15, 3, 7]andkof17, retur...
2018-12-22 06:20:00
77
转载 [Daily Coding Problem] 18 (LeetCode 239). Sliding Window Maximum
Given an arraynums, there is a sliding window of sizekwhich is moving from the very left of the array to the very right. You can only see theknumbers in the window. Each time the sliding win...
2018-12-22 06:01:00
91
转载 [Daily Coding Problem 24] Implement locking in a binary tree.
This problem was asked by Google.Implement locking in a binary tree. A binary tree node can be locked or unlocked only if all of its descendants or ancestors are not locked.Design a binary tr...
2018-12-22 02:35:00
121
转载 [LeetCode] 208(LintCode). Implement Trie(Prefix Tree)
Implement a trie with insert, search, and startsWith methods.NoticeYou may assume that all inputs are consist of lowercase letters a-z.Exampleinsert("lintcode")sea...
2018-12-15 05:59:00
78
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人