上一页 1 2 3 4 5 6 7 ··· 21 下一页
摘要: https://leetcode.cn/problems/subarray-product-less-than-k/description/ 同向双指针,没什么难点 class Solution { int res; public int numSubarrayProductLessThanK(in 阅读全文
posted @ 2024-10-06 00:24 风乐 阅读(12) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/longest-substring-without-repeating-characters/description/ 同向双指针问题,利用hashmap判重 class Solution { int res; public int leng 阅读全文
posted @ 2024-10-06 00:22 风乐 阅读(18) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/koko-eating-bananas/description/ 二段性:速度有得完和不吃完两个段关键点是编写check函数,比较繁杂 class Solution { public int minEatingSpeed(int[] pile 阅读全文
posted @ 2024-09-27 15:40 风乐 阅读(19) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/find-peak-element/description/ class Solution { public int findPeakElement(int[] nums) { // 需要依据题意来证明一个定理 // i~n-1中切nums[ 阅读全文
posted @ 2024-09-27 02:05 风乐 阅读(23) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/split-array-largest-sum/description/ 比较难的二分,关键点在于看出二段性,段数越多最大值越小,段数越小最大值越大,二分最大值,然后就是最大值的合法性校验(判断段数<=k),用于二分的check class 阅读全文
posted @ 2024-09-26 17:42 风乐 阅读(19) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/trapping-rain-water/description/大厂经典题,接雨水暴力双指针->预处理优化->单调栈 暴力: class Solution { public int trap(int[] height) { // 暴力解法: 阅读全文
posted @ 2024-09-23 00:46 风乐 阅读(16) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/next-greater-element-ii/description/ class Solution { public int[] nextGreaterElements(int[] nums) { // 成环的单调栈题,思路1:将nums 阅读全文
posted @ 2024-09-16 03:45 风乐 阅读(21) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/next-greater-element-i/description/ 根据校验nums2中的元素是否存在于nums1中 的时机 分为不同做法 class Solution { public int[] nextGreaterElement( 阅读全文
posted @ 2024-09-15 17:17 风乐 阅读(16) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/daily-temperatures/description/ 经典单调栈,关键难点在于如何利用单调栈这个数据结构解题题意要求向右找到第一个比当前大的元素,若是暴力则是O(n^2),但是依据暴力的这个思想可以利用单调栈优化,因为求右边第一个比 阅读全文
posted @ 2024-09-15 16:45 风乐 阅读(29) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/all-paths-from-source-to-target/description/ class Solution { List<List<Integer>> res = new ArrayList<>(); int[][] g; // 阅读全文
posted @ 2024-09-14 01:32 风乐 阅读(22) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 ··· 21 下一页