How to Solve "Making Anagrams" on HackerRank? - Javascript Strings

Опубликовано: 28 Сентябрь 2024
на канале: Coding David
1,914
23

Do you need more help with coding?
════════════════════════════
✅ Apply for 1-1 coaching https://form.jotform.com/230156286763056
════════════════════════════

How to Solve "Making Anagrams" on HackerRank?

Category: Strings
Problem: Making Anagrams
Difficulty: Easy
Language: Javascript

Time Complexity: O(n+m)
Space Complexity: O(n)

Pseudo Code:
1. Create a count variable.
2. Create a map object.
3. Loop through a.
a. If the character is not in the map,
i. Add the character and set the value to 1.
b. Else,
i. Increment the value.
4. Loop through b.
a. If the character is in the map,
i. Decrement the value.
b. Else,
i. Increment count.
5. Loop through map.
a. Add the count by the value of each key.
6. Return count.

Let's Connect 💯:
════════════════════════════
LinkedIn:   / anusontarangkul  
TikTok:   / david.anu_  
Instagram:   / david.anu_  
GitHub: https://github.com/anusontarangkul