2022年10月30日

今日总结

摘要: ##784. 字母大小写全排列 回溯; class Solution { List ans = new ArrayList<>(); public List letterCasePermutation(String s) { dfs(s.toCharArray(), 0); return ans; 阅读全文

posted @ 2022-10-30 14:46 xtdnn 阅读(23) 评论(0) 推荐(0)

2022年10月29日

总结复盘

摘要: ##88. 合并两个有序数组 合并; 排序; for(int i = 0; i < n; i++) { nums1[i + m] = nums2[i]; } Arrays.sort(nums1); ##80. 删除有序数组中的重复项 II int left = 1, righe = 1; while 阅读全文

posted @ 2022-10-29 16:37 xtdnn 阅读(38) 评论(0) 推荐(0)

2022年10月27日

全都有

摘要: ##79. 单词搜索 搜索啦, 模板啦; 条件判断,函数本身; 还有回溯勿忘; if(k == word.length()) return true; if(i < 0 || j < 0 || i >= board.length || j >= board[0].length || board[i] 阅读全文

posted @ 2022-10-27 16:53 xtdnn 阅读(184) 评论(0) 推荐(0)

2022年10月26日

每日一结

摘要: ##862. 和至少为 K 的最短子数组 求出一个数组,sum[i] = 前i个数字之和; 和至少为k,最简单的是两层遍历; 为了时间快一些,可以采用栈来存放下标; for(int i = 0; i <= n; i++) { long cur = sum[i]; while(!deque.isEmp 阅读全文

posted @ 2022-10-26 17:23 xtdnn 阅读(20) 评论(0) 推荐(0)

2022年10月25日

数组

摘要: ##915. 分割数组 int index = 0, leftMax = nums[0], max = nums[0]; for(int i = 1; i < nums.length; i++) { if(leftMax > nums[i]) {//加上等号,可能会出现没有右数组 index = i 阅读全文

posted @ 2022-10-25 09:22 xtdnn 阅读(9) 评论(0) 推荐(0)

2022年10月24日

回溯剪枝

摘要: ##39. 组合总和 & 40. 组合总和 II 前者数组中的数字可以重复, 后者不可以; 前者数组中无重复数字, 后者有; 前者不需要排序,后者需要; 前者: dfs(candidates, i, target - candidates[i]); 后者: dfs(candidates, i + 1 阅读全文

posted @ 2022-10-24 12:02 xtdnn 阅读(22) 评论(0) 推荐(0)

2022年10月23日

每日一结

摘要: ##16. 最接近的三数之和 for(int i = 0; i < nums.length - 2; i++) while(l < r) { int cur = nums[i] + nums[l] + nums[r]; if(Math.abs(cur - target) < Math.abs(clo 阅读全文

posted @ 2022-10-23 11:09 xtdnn 阅读(11) 评论(0) 推荐(0)

2022年10月22日

今日复习

摘要: ##15. 三数之和 先排序; 遇到重复数字时直接 continue;以免答案重复; 注意在内层,将问题转化为两数之和采用双指针解决时; 利用多分枝的条件判断以减少时间; while(second < thrid && (nums[second] + nums[thrid]) > targer) t 阅读全文

posted @ 2022-10-22 19:53 xtdnn 阅读(24) 评论(0) 推荐(0)

2022年10月21日

每日一结

摘要: ##901. 股票价格跨度 需要求出不超过当前股票价格的天数; 设置两个栈; 一个存储价格: 是一个单调栈,因为如果今天的价格比之前的高,那么之前的价格对后续不会产生影响; 所以: while(!prices.isEmpty() && prices.peekLast() <= price) {//" 阅读全文

posted @ 2022-10-21 17:22 xtdnn 阅读(12) 评论(0) 推荐(0)

2022年10月20日

复习 + 总结

摘要: ##剑指 Offer 14- II. 剪绳子 II 因为本体涉及到了大数运算带来的溢出问题; 所以可以 import java.math.BigInteger; ##剑指 Offer 39. 数组中出现次数超过一半的数字 HashMap; ##剑指 Offer 57 - II. 和为 s 的连续正数 阅读全文

posted @ 2022-10-20 09:41 xtdnn 阅读(24) 评论(0) 推荐(0)

导航