-
Category: PS – LeetCodeTag: hashmap
Difficulty: EasyTopics: Array, Hash Table Question Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer… Read more
-
Category: Algorithm NotesTag: hashmap
Basic Usages unordered_map<int, int> hashmap;// 2. insert a new (key, value) pairhashmap.insert(make_pair(2, 3));// 3. insert a new (key, value) pair or update the value of existed keyhashmap[1] = 1;hashmap[1] = 2;// 4. get the value of a specific keyhashmap[1]// 5. delete a keyhashmap.erase(2);// 6. check… Read more
-
Category: PS – LeetCode

Question Difficulty: mediumTopics: Array, Two Pointers, Binary Search, Sliding Window Given a sorted integer array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending order. An integer a is closer to x than an integer b if: Example 1:Input: arr = [1,2,3,4,5], k = 4, x… Read more
-
Category: PS – LeetCode
Difficulty: mediumTopics: math, recursion Implement pow(x, n), which calculates x raised to the power n Example 1: Input: x = 2.00000, n = 10 Output: 1024.00000 Example 2: Input: x = 2.10000, n = 3 Output: 9.26100 Example 3: Input: x = 2.00000, n =… Read more
-
Category: PS – LeetCodeTag: binary search
Difficulty: mediumTopics: array, binary search Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. If target is not found in the array, return [-1, -1]. You must write an algorithm with O(log n)… Read more
-
Category: Milestones / ReflectionsTag: plans
There is a question that doesn’t seem to leave my mind these days. Have I ever passionately devoted my time on something, losing the track of time and surroundings? Have I ever experienced a graceful failure, one that I feel no remorse or sadness as… Read more