Do you need more help with coding?
════════════════════════════
✅ Apply for 1-1 coaching https://form.jotform.com/230156286763056
Problem: #1790 Check if One String Swap Can Make Strings Equal
Language: #Javascript
Difficulty: Easy
Strategy: Create character array and keep swap counts.
Time Complexity: O(n)
Space Complexity: O(1)
Pseudo Code:
1. Create a charArray variable.
2. Create a swap variable.
3. Loop through s1.
a. Add the value to the corresponding charArray.
4. Loop through s2.
a. Condition if current value is not inside charArray.
i. Return false.
b. Else
i. Decrement the value in charArray.
c. Condition if s1[i] != s[2].
i. Swap++.
d. Condition if swap is greater than 2
i. Return false.
5. Return true.
*This is just one possible solution. It may not be the most optimal.
Let's Connect 💯:
════════════════════════════
LinkedIn: https://www.linkedin.com/in/anusontarangkul/
TikTok: https://www.tiktok.com/@david.anu_
Instagram: https://www.instagram.com/david.anu_/
GitHub: https://github.com/anusontarangkul
Download
0 formats
No download links available.
How to Solve "1790 Check if One String Swap Can Make Strings Equal" on LeetCode? - Javascript | NatokHD