HashMap = Dictionary in python
The point of this problem is to create a HashMap that stores the counts of the letters that appears in magazine, and subtract counts if the same letter is in ransomNote.
The problem was setting the if conditions,
1. char must be in the counter (obiviously), otherwise we cannot make ransomNote with magazine
2. Each letter should be used once in magazine, so the word counter should be more that 0 when faced with a char.
* Can make a dictionary through dict() and check if there exists something (look up)
'LeetCode' 카테고리의 다른 글
[Two Pointer technique] (0) | 2024.09.23 |
---|---|
[String] Find the Index of the First Occurrence in a String (0) | 2024.09.23 |
[String] Add Binary (0) | 2024.09.18 |
[2D Array] Spiral Matrix (1) | 2024.09.18 |
[Linked List] Middle of the Linked List (0) | 2024.09.15 |