程序媛詹妮弗
终身学习
摘要: [leetcode]1. Two Sum两数之和 Two Pointers, HashMap Easy [leetcode]2. Add Two Numbers两数相加 Math, LinkedList Medium [leetcode]3. Longest Substring Without Re 阅读全文
posted @ 2019-04-03 06:26 程序媛詹妮弗 阅读(296) 评论(0) 推荐(0) 编辑
摘要: Map常用场景 # map来track每个元素的index Map <item, index> map = new HashMap<>(); # map来track每个元素出现的频率 Map <item, freq> map = new HashMap<>(); # char字符在ASCII中都有对 阅读全文
posted @ 2021-01-03 04:10 程序媛詹妮弗 阅读(77) 评论(0) 推荐(0) 编辑
摘要: 何时用dummy 给定链表的head结点可能最先被删除/移动? Yes-> 无脑用dummy ListNode dummy = new ListNode(-1); ListNode pre = dummy; dummy.next = head; ... return dummy.next; 反转链表 阅读全文
posted @ 2020-12-30 12:17 程序媛詹妮弗 阅读(123) 评论(0) 推荐(0) 编辑
摘要: Stack特点: 先入后出(FILO) Stack常见的创建方式: Stack<Character> stack = new Stack<>() Stack常见操作: stack.size()stack.isEmpty() stack.push(val) stack.pop() //在该操作前,确保 阅读全文
posted @ 2020-12-29 11:50 程序媛詹妮弗 阅读(84) 评论(0) 推荐(0) 编辑
摘要: Two Pointers(指针i扫旧, 指针start上新)模板: *用指针start帮助生成新数组。指针start指向下一个即将生成的,符合条件的元素的位置。 // save a position for next valid item *用指针i扫给定数组A *若扫到的A[i]符合新数组对元素的 阅读全文
posted @ 2020-12-29 05:58 程序媛詹妮弗 阅读(142) 评论(0) 推荐(0) 编辑
摘要: Given an array of n integers nums and an integer target, find the number of index triplets i, j, k with 0 <= i < j < k < n that satisfy the condition  阅读全文
posted @ 2020-12-29 05:36 程序媛詹妮弗 阅读(115) 评论(0) 推荐(0) 编辑
摘要: K Sum模板: *如果返回特定index,用HashMap *如果返回组合本身且 K > 2, 无论如何先Arrays.sort(nums), 再降为TwoSum问题(指针对撞) public int[] twoSumII(int[] numbers, int target) { int i = 阅读全文
posted @ 2020-12-29 05:16 程序媛詹妮弗 阅读(107) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function 阅读全文
posted @ 2020-12-29 05:12 程序媛詹妮弗 阅读(133) 评论(0) 推荐(0) 编辑
摘要: Sliding Window模板 public int slidingWindowTemplate(String s, String t) { Map<Character, Integer> map = new HashMap<>(); int result = 0; int counter = m 阅读全文
posted @ 2020-12-29 03:15 程序媛詹妮弗 阅读(80) 评论(0) 推荐(0) 编辑
摘要: Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. 阅读全文
posted @ 2020-12-29 02:58 程序媛詹妮弗 阅读(148) 评论(0) 推荐(0) 编辑
摘要: Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. The update(i, val) function modifies nums by upd 阅读全文
posted @ 2019-08-23 06:26 程序媛詹妮弗 阅读(250) 评论(0) 推荐(0) 编辑