07 2022 档案
摘要:What is a complete binary tree? A complete binary tree is a binary tree in which all the levels except the last level, i.e., leaf node should be compl
阅读全文
摘要:binary search binary search time complexity = O(logn) the question usually give you a sorted array and then find a target(index) in the value: the big
阅读全文
摘要:不是O(N^2) ,是O(N)。两个指针遍历了整个数组一次 时间复杂度与最内层循环主体的执行次数有关与有多少重循环无关. The time complexity is related to the number of executions of the innermost loop body, in
阅读全文
摘要:228 · Middle of Linked List 快慢指针 慢走1, 快每次走2 初始化的时候 slow = head; fast =head.next; 并且 while的时候 java是从左到右检查 while(last!=null && last.next!=null) 如果写成 whi
阅读全文
摘要:旋转数组: 1790 · Rotate String II: 这里需要注意的是substring的 indexstart :inclusive, indexend: exclusive 2.offset need to be modulo int offset = (left - right) %
阅读全文
摘要:Type argument cannot be primitive type ~~HashMap<Integer,boolean> hashMap = new HashMap<Integer, boolean>();~~ it should use Boolean instead of boolea
阅读全文
摘要:Approach 4: Using Hashmap Algorithm The idea behind this approach is as follows: If the cumulative sum(represented by sum[i]sum[i] for sum up to i^{th
阅读全文
摘要:Trie: 前缀树 递归:如果每一层循环的内容都是一样的操作,那么可以用递归。
阅读全文
摘要:Note: String objects are stored in a special memory area known as the "string constant pool". features - immutable str is a string make string sorted;
阅读全文
摘要:you can't initialize array like this way: public static final String dic[4] = {"33","3","4","5"}; I don't know why you can't assign the length of the
阅读全文