Decoding the Fast & Slow Two Pointer Algorithm to Find Cycles in Javascript Part 2 of 3

Опубликовано: 10 Апрель 2026
на канале: Coderbyte
2,518
50

In this video, we continue our two-pointer series where we leverage two different pointers at two different speeds. This approach is useful with cyclic linked lists or arrays and is used in the tortoise and hare problem.

The Challenge (Medium Difficulty):
Given an integer, write a function to determine if after repeatedly replacing it with an integer equal to the sum of the square of all of its digits, leads us to the number 1.

Video Overview:
0:38 Review
1:40 Problem
5:11 Hare & tortoise approach
7:34 Javascript solution
17:46 Recap

Please subscribe to our channel!

Check out our Tiktoks @coderbyte

Additional Resources:
Practice hundreds of real coding challenges at https://coderbyte.com/
Need more practice? Check out our channel for more videos on preparing for a coding interview    / coderbytedevelopers