반응형
hi.
I have another question about a LeetCode problem.
First, please check what the problem is.
It's quite a simple one, but it was hard to implement in code.
I'm not an AI, so it's really difficult to explain in a programming language.
I tried using the substr and includes methods,
but they didn't work properly.
They couldn't cover all the cases.
So... I googled the answer and re-realized the power of recursion.
The key is to keep dividing the elements until we find the same one.
The code on the right side is the correct one.
reference : https://mindevlog.tistory.com/254
반응형
'열정가득한 개발자의 이야기 > Javascript Algorithm' 카테고리의 다른 글
1768. Merge Strings Alternately (JS) (0) | 2025.03.23 |
---|---|
151. Reverse Words in a String (Javascript) (0) | 2025.03.20 |
643. Maximum Average Subarray I with JS (0) | 2025.02.28 |
leetcode 575. Distribute Candies (javascript) (1) | 2025.01.27 |
500. Keyboard Row (javascript) (0) | 2025.01.26 |