经典回溯,推荐下代码随想录的讲解,回溯我看的他的讲解,易懂 收集问题和分割、组合问题的不同,就是要在终止条件上面添加个,不然会漏掉自己 class Solution {List<List<Integer>> result = new ArrayList<>();LinkedList<Integer> path = new LinkedList<>();public List<List<Integ
class Solution {public int findMaxForm(String[] strs, int m, int n) {if (strs.length == 0) return 0;int[][] dp =new int[m+1][n+1];//strs 数组里的元素就是物品,m和n是背包,二维的背包// 遍历物品,字符串中有各个字符for(String s :strs) {in
class Solution {public int[] maxSlidingWindow(int[] nums, int k) {if(nums == null || nums.length == 0) return new int[0];int[] result = new int[nums.length - k + 1];Deque<Integer> queue = new ArrayDeq
class Solution {// 滑动窗口public int findLHS(int[] nums) {Arrays.sort(nums);int left = 0, res = 0;for(int right = 0; right < nums.length; right++){while(nums[right] - nums[left] > 1){++left;}if(nums[righ