摘要:
[leetcode]1. Two Sum两数之和 Two Pointers, HashMap Easy [leetcode]2. Add Two Numbers两数相加 Math, LinkedList Medium [leetcode]3. Longest Substring Without Re 阅读全文
摘要:
Two Pointers(指针i扫旧, 指针start上新)模板: *用指针start帮助生成新数组。指针start指向下一个即将生成的,符合条件的元素的位置。 // save a position for next valid item *用指针i扫给定数组A *若扫到的A[i]符合新数组对元素的 阅读全文
摘要:
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 阅读全文
摘要:
K Sum模板: *如果返回特定index,用HashMap *如果返回组合本身且 K > 2, 无论如何先Arrays.sort(nums), 再降为TwoSum问题(指针对撞) public int[] twoSumII(int[] numbers, int target) { int i = 阅读全文
摘要:
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 阅读全文
摘要:
Sliding Window模板 public int slidingWindowTemplate(String s, String t) { Map<Character, Integer> map = new HashMap<>(); int result = 0; int counter = m 阅读全文
摘要:
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. 阅读全文
摘要:
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 阅读全文