
笔记
金九银十!!
这个作者很懒,什么都没留下…
展开
-
最长重复子串
class Solution { long mod = (long)Math.pow(2, 37) - 1; long a = 26; int nums[]; int n; public String longestDupSubstring(String S) { nums = new int [S.length()]; for (int i = 0; i < S.length(); i ++) { num原创 2020-10-21 20:12:08 · 168 阅读 · 0 评论 -
前缀树
class Trie { TrieNode root; /** Initialize your data structure here. */ public Trie() { root = new TrieNode(); } /** Inserts a word into the trie. */ public void insert(String word) { TrieNode cur = root;原创 2020-10-15 20:37:59 · 113 阅读 · 0 评论 -
前缀树
class Trie { private final int SIZE = 26; private TrieNode root; // TrieNode class TrieNode { // 多少单词通过这个节点,即由根至该节点组成的字符串模式出现的次数 private int num; // 所有的儿子节点 private TrieNode[] son; // 是不是最后一个节点原创 2020-10-15 20:31:10 · 135 阅读 · 0 评论 -
前缀树
在这里插class Trie { private final int ALPHABET_SIZE = 26; private Trie[] children = new Trie[ALPHABET_SIZE]; boolean isEndOfWord = false; public Trie() {} public void insert(String word) { Trie tmp = this; for (char i原创 2020-10-15 20:27:02 · 104 阅读 · 0 评论 -
2020-09-26
class Solution { public int tilingRectangle(int n, int m) { int INF = 0x3f3f3f3f; int[][] dp = new int[n + 1][m + 1]; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ //如果是正方形原创 2020-09-26 20:02:14 · 87 阅读 · 0 评论 -
2020-09-23
// javaclass Solution { public int longestCommonSubsequence(String text1, String text2) { int m = text1.length(), n = text2.length(); int[][] dp = new int[m + 1][n + 1]; for (int i = 0; i < m; i++) { for (int j原创 2020-09-23 19:39:09 · 77 阅读 · 0 评论 -
2020-09-18
import java.util.ArrayDeque;import java.util.ArrayList;import java.util.Arrays;import java.util.Deque;import java.util.List;public class Solution { public List<List<Integer>> combinationSum(int[] candidates, int target) { int原创 2020-09-18 18:57:04 · 158 阅读 · 0 评论 -
2020-09-15
class Solution { private class LargerNumberComparator implements Comparator<String> { @Override public int compare(String a, String b) { String order1 = a + b; String order2 = b + a; return order原创 2020-09-15 17:09:24 · 82 阅读 · 0 评论 -
2020-09-15
class Solution { private class LargerNumberComparator implements Comparator<String> { @Override public int compare(String a, String b) { String order1 = a + b; String order2 = b + a; return order2.com原创 2020-09-15 17:08:53 · 93 阅读 · 0 评论 -
2020-09-14
class Solution { public String rearrangeString(String s, int k) { if(s == null || s.length() == 0){ return s; } HashMap<Character, Integer> hm = new Integer>(); for(int i = 0; i<s.length(); i++){原创 2020-09-14 20:53:21 · 93 阅读 · 0 评论 -
2020-09-14
class Solution { public double[] medianSlidingWindow(int[] nums, int k) { double[] result = new double[nums.length - k + 1]; if (k == 1) { for (int i = 0; i < result.length; i ++) { result[i] = (double) nu原创 2020-09-14 19:48:04 · 88 阅读 · 0 评论 -
2020-09-13
class Solution { public List<List<Integer>> threeSum(int[] nums) { Arrays.sort(nums); List<List<Integer>> res = new ArrayList<>(); for(int k = 0; k < nums.length - 2; k++){ if(nums[k]原创 2020-09-13 16:19:37 · 112 阅读 · 0 评论 -
2020-09-09
class Solution { public boolean exist(char[][] board, String word) { boolean[][] visited = new boolean[board.length][board[0].length]; for (int i = 0; i < board.length; i++) { for (int j = 0; j < board[0].length; j++)原创 2020-09-09 20:19:41 · 113 阅读 · 0 评论 -
2020-09-09
class Solution {public boolean exist(char[][] board, String word) {boolean[][] visited = new boolean[board.length][board[0].length];for (int i = 0; i < board.length; i++) {for (int j = 0; j < board[0].length; j++) {if (word.charAt(0) == board[i]原创 2020-09-09 20:17:52 · 83 阅读 · 0 评论 -
2020-09-09
class Solution { public List<List<Integer>> pacificAtlantic(int[][] matrix) { List<List<Integer>> res = new ArrayList<>(); if(matrix == null || matrix.length == 0){ return res; }原创 2020-09-09 19:17:20 · 142 阅读 · 0 评论