Already Seen Flags
For every position i of nums, decide whether the value nums[i] already appeared at an earlier position of the list.
Return a list of booleans with the same length as nums: True where the value was seen before, False where the value appears for the first time. The empty list gives [].
Example 1
nums [1,2,1,3,2]
returns [false,false,true,false,true]
The second 1 and the second 2 are repeats; everything else is new.
Example 2
nums [5,5,5]
returns [false,true,true]
The first 5 is new, the next two are repeats.
Constraints
0 <= len(nums) <= 100-1000 <= nums[i] <= 1000
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Hash maps problems
- Best Score per NameBeginner
- Check if the Sentence Is PangramBeginner
- Count Elements With a NextBeginner
- Difference of Two ArraysBeginner
- First Repeated WordBeginner
- Is IsogramBeginner
- Jewels and StonesBeginner
- Keep First of Each LetterBeginner