3:39

Ray Deck shows how to split a flat list of integers into groups of consecutive numbers. Using a foreach loop that tracks the previous value, the code detects gaps larger than 1, closes the current group, and starts a new one. The example [1,2,3,5,6,7,8,9,11,12,13] produces three groups: [1,2,3], [5,6,7,8,9], and [11,12,13].

Chapters

More from Ray

youtube.com

Be the Looker

7mo ago
youtube.com

Operators Optimize, Innovators Integrate

7mo ago
youtube.com

Move Over Vibe Coding

7mo ago
youtube.com

Two Customer Challenges

7mo ago
youtube.com

Trust is a Competitive Moat

7mo ago
youtube.com

Be Verbose With Your Errors

7mo ago
youtube.com

Build for AI, Not Just With It

7mo ago
youtube.com

A Technology Business

7mo ago
youtube.com

Interdimensional Studying

7mo ago
youtube.com

Interdimensional Learning

7mo ago
youtube.com

Gain True Mastery

7mo ago
See all content