LeetCode Weekly Contest 156 and others
Second week of LeetCode Challenge. Participated the virtual contest.
Weekly Contest 156
1207. Unique Number of Occurrences
Brute force. Record total occurrence of each number and iterate over it to see if there is any duplication.
1208. Get Equal Substrings Within Budget
Two pointers. Let’s think it in this way: at the starting position, if we can go to the next character in the string and does not exceed the maximum cost, do so and keep doing it until we can’t. Then in order to extend the length of sub-string, we must “release” the cost of changing one character at the beginning of the sub-string, so that the next character has some costs available to use in order to hold the maximum bound.
1209. Remove All Adjacent Duplicates in String II
Stack approach. Whenever encounter a new character, push the character with count
1 into the stack. Increment the counter if the next character is the same as the top of the stack.
If the counter reaches
k, then just remove it from the stack as it’s valid adjacent duplicates.
1210. Minimum Moves to Reach Target with Rotations
BFS. This question is not hard while you got the implementation right. Check all possible moves.