1657. Determine if Two Strings Are Close | JavaScript | LeetCode Daily Challenge | O(N) TC

preview_player
Показать описание
#leetcode #javascript #coding #leetcodedailychallenge
Рекомендации по теме
Комментарии
Автор

I think it is redundent to run the while loop after you already check which is in the arr1 and arr2. Just join() the both array after sort then check equality is enough I guess.
return arr1.sort((a, b) => a - b).join("") === arr2.sort((a, b) => a - b).join("");

ktm