随笔分类 - 力扣分类题解
主要是力扣上HOT100和剑指offer以及目前笔试遇到过的一些题,将他们按题解分类放在一起
    
摘要:力扣 39组合总和 public class combinationSum_1 { static List<List<Integer>> res; static LinkedList<Integer> tmp ; public static List<List<Integer>> combinati
        阅读全文
                
摘要:力扣 200 岛屿数量 public class numIslands_1 { private int res; public int numIslands(char[][] grid) { res = 0; for(int i = 0; i < grid.length; i++){ for(int
        阅读全文
                
摘要:力扣 139单词拆分 写法1 class Solution { Boolean[] visited; List<String> wordDict; String s; public boolean wordBreak(String s, List<String> wordDict) { visite
        阅读全文
                
摘要:dfs+回溯写题两种思路 主要框架 public void dfs(选择列表){ //1.找到结束条件 //2.遍历所有可能性 //2.1做选择 //2.2 递归调用自己进一步深度遍历 //3.回撤选择 } dfs函数的参数变量我觉得是越少越好,所以将一些不怎么改变的变量设置为全局变量更容易理清思路
        阅读全文
                
摘要:滑动窗口 public static int subarraySum(int[] nums, int k) { int l = 0, r = 0; while(r < nums.length){ // 1. r 向右移动 // 2.满足条件了,l向右移动 while(满足或者超过预期){ l++; 
        阅读全文
                
摘要:括号问题 [1] 力扣22. 括号生成 问题描述 括号生成 数字 n 代表生成括号的对数,请你设计一个函数,用于能够生成所有可能的并且 有效的 括号组合。 示例 1: 输入:n = 3 输出:["((()))","(()())","(())()","()(())","()()()"] 示例 2: 输
        阅读全文
                
                    
                
浙公网安备 33010602011771号