How to Solve "1160 Find Words That Can Be Formed by Characters" on LeetCode - Javascript
Описание
Do you need more help with coding?
════════════════════════════
✅ Apply for 1-1 coaching https://form.jotform.com/230156286763056
════════════════════════════
Problem: #1160 Find Words That Can Be Formed by Characters
Language: Javascript
Difficulty: Easy
Strategy: Array to keep track of characters
Time Complexity: O(n*m)
Space Complexity: O(n)
Pseudo Code:
1. Create output variable.
2. Create new array of 26 indices to 0.
3. Loop through chars.
a. Change to ASCII and increment at the corresponding value.
4. Loop through words.
a. Create a new temp array from the old array.
b. Create charCount variable.
c. Loop through the word.
i. Condition to see if that current value is in the array.
1. Increment CharCount.
2. Minus the index value from it.
d. Create condition if charCount is equal to the length of the word.
i. Add output the length.
GitHub Repo:
https://github.com/anusontarangkul/leetcode-javascript-solutions/blob/main/1160-Find-Words-That-Can-Be-Formed-by-Characters/1160.js
Let's Connect ?:
════════════════════════════
LinkedIn: https://www.linkedin.com/in/anusontarangkul/
TikTok: https://www.tiktok.com/@coding_david
Instagram: https://www.instagram.com/coding_david_/
GitHub: https://github.com/anusontarangkul
Рекомендуемые видео



















