Require a very special algo. In place modification makes it more difficult. A good practice for moving pointer…
Not conspicuous at first but two pointer could be helpful.
Description
The technique of greedy algorithm is keeping a fluctuating local variable, reinitiating the local variable when necessary, and updating the global variable with the fluctuating local variable.
A good practice for switching the “next”. The sequence of assigning variable is critical.
This question is relatively practical as LRU Cache is often used in page table in operating system and buffer manager in database.
Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.
Require a very special algo. To avoid nums[i] affetcs res[i], make append/update of res[i] prior to nums[i]’s intervention.
An extension from Valid Anagram. Unicode characters would not be inputs in this problem, so sorting will do the trick.
Given an array of strings strs, group the anagrams together. You can return the answer in any order.
strs
A classic question. Hash is the most popular solution.