摘要:
层次遍历 思路:按层遍历每一个节点,将每一层的节点相连接 /* // Definition for a Node. class Node { public int val; public Node left; public Node right; public Node next; public N 阅读全文
摘要:
BFS 使用一个队列,从左向右遍历每一层,将每层最右侧的节点值加入答案当中 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; 阅读全文
摘要:
递归 遍历字符串S中的字符,如果是字母则将之前的全排列复制一份,并添加当前字母的大小写,如果不是字母则直接添加该字符 class Solution { public List<String> letterCasePermutation(String S) { List<StringBuffer> a 阅读全文
摘要:
动态规化 class Solution { class job { int start, end, profit; job (int s, int e, int p) { start = s; end = e; profit = p; } } public int jobScheduling(int 阅读全文
摘要:
class Solution { public String longestDupSubstring(String S) { int n = S.length(); int[] nums = new int[n]; // 字符串转为数组 for (int i = 0; i < n; i++) { n 阅读全文
摘要:
二分查找 class Solution { public int superEggDrop(int K, int N) { return dp(K, N); } Map<Integer, Integer> memo = new HashMap<>(); private int dp(int K, i 阅读全文