Hi! Long time no see.
Today, I studied linked lists. I think they’re kind of difficult for me, but I’m trying to organize what I’ve learned.
Before I explain the problem, I want to say — this problem actually reminds me of one of my life mottos.
It’s a Korean saying: “People who are meant to meet will meet someday.”
It means that if someone is meant to be a part of my life, I’ll eventually meet them — no matter what.
And this problem is just like that.
To summarize: there are two pointers.
One moves one step at a time, and the other moves two steps.
At the beginning, they both start at the same point.
Then they move at different speeds, but in the same direction.
If there is a cycle in the linked list, they will eventually meet — just like destiny.
But if there’s no cycle, they’ll never meet, and the function will return false.
'열정가득한 개발자의 이야기 > Javascript Algorithm' 카테고리의 다른 글
1768. Merge Strings Alternately (JS) (0) | 2025.03.23 |
---|---|
1071. Greatest Common Divisor of Strings (JS) (0) | 2025.03.22 |
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 |