86 -- 9:13 App LeetCode刷题日记 Day 25 Part 1 - Rotting Oranges 79 -- 7:47 App LeetCode刷题日记 Day 30 Part 3 - Implement Trie (Prefix Tree) 78 -- 9:48 App LeetCode刷题日记 Day 23 Part 2 - Search in Rotated Sorted Arra
return the max subsequence of length L, then we can solve this problem. This can be solved using dp in O(N^2) time. Since the array can be pretty long and to avoid integer overflow, I decided to use a 2D StringBuilder dp[i][j] to represent the max sequence of length j out of...
Additionally, there are city restrictions on the maximum height of specific buildings. These restrictions are given as a 2D integer arrayrestrictionswhererestrictions[i] = [idi, maxHeighti]indicates that buildingidimust have a height less than or equal tomaxHeighti. It is guaranteed that each bui...
Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array[2,3,-2,4], the contiguous subarray[2,3]has the largest product =6 思路:从左至右遍历数组,记录下以当前所遍历到的元素结尾的子数组积的最大值和最小值(...
725. Split Linked List in Parts.md 729. My Calendar I.md 731. My Calendar II.md 796. Rotate String.md 874. Walking Robot Simulation.md 884. Uncommon Words from Two Sentences.md 917. Reverse Only Letters.md 921. Minimum Add to Make Parentheses Valid.mdBreadcrumbs leetcodeDaily...
[LeetCode] 1840. Maximum Building Height You want to build n new buildings in a city. The new buildings will be built in a line and are labeled from 1 to n. However, there are city restrictions on the heights of the new buildings:...
1260-shift-2d-grid.cpp 1299-Replace-Elements-with-Greatest-Element-on-Right-Side.cpp 1299-replace-elements-with-greatest-element-on-right-side.cpp 1343-number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold.cpp 1448-Count-Good-Nodes-In-Binary-Tree.cpp 1448-count-good...
[LeetCode]Maximum number of points on a straight line in 2d plane From Here Solution: Remember that a line can be represented by y=kx+d, if p1 and p2 are in same line, then y1=x1k+d, y2=kx2+d, so y2-y1=kx2-kx1, so k=(y2-y1)/(x2-x1), then we can apply this form...
LeetCode C++ 1742. Maximum Number of Balls in a Box【Array】简单 You are working in a ball factory where you have n balls numbered from lowLimit up to highLimit inclusive (i.e., n == highLimit - lowLimit + 1), and an infinite number of boxes numbered from 1 to infi......
I found this question in one of the interview challenge. I used the traditional sum of subsets logic to find all the possible sum for n elements and then tried to reconstruct non-overlapping subsets for a sum from the 2D DP array. I couldn't get all tc to pass. Is there any better ...