01 2021 档案
摘要:暴力解法很容易,JAVA 暴力解法: public final ListNode mergeKLists(ListNode[] lists) { ListNode head = new ListNode(0); ListNode node = head; while (true) { int min
阅读全文
摘要:多种解题方式,位计数感觉最精彩。 JAVA Hash表: public final int findDuplicate(int[] nums) { Set<Integer> set = new HashSet<Integer>(); for (int i = 0; i < nums.length;
阅读全文
摘要:相比起暴力解法,前缀树可以实现空间换时间。将多个 small 构建为一棵前缀树,在树上遍历一次 big 。可替代用每个 small 与 big 比对。 JAVA: private class Trie { boolean isEnd; Trie[] childs; int num; int flag
阅读全文
摘要:JAVA 暴力解法,这一步是比较难的,该思路我称之为左右逢源。视角放在局部,每个元素对应的结果与左右所有元素相关: public final int trap(int[] height) { int re = 0, len = height.length; for (int i = 1; i < l
阅读全文
摘要:package Demo.qd; import com.itextpdf.awt.geom.Rectangle2D.Float; import com.itextpdf.text.pdf.PdfDictionary; import com.itextpdf.text.pdf.PdfName; imp
阅读全文
摘要:JAVA: class WordDictionary { private Node head; /** * Initialize your data structure here. */ public WordDictionary() { this.head = new Node(null); }
阅读全文
摘要:JAVA 实现: class Trie { private Node head; /** * Initialize your data structure here. */ public Trie() { this.head = new Node(); } /** * Inserts a word
阅读全文
摘要:JAVA: public List<List<String>> suggestedProducts(String[] products, String searchWord) { Node head = initTree(products); List<List<String>> reList =
阅读全文