โ† LessonsBUILDER PATH ยท 7โ€“9๐Ÿ 

Reef Pointer Pairs

LESSON 144
๐ŸŽฏ Today's missions
๐Ÿ ๐Ÿš๐Ÿซง
OCEAN LAB

Reef Pointer Pairs

A row of shells lies on the reef, sorted from lightest to heaviest. Two shells must weigh exactly 20 together to open the treasure clam. Use two pointers, one at each end, to find them fast.

๐Ÿง  Before we start

Stage Sliding Spotlight moved one frame along a list. Today two markers move toward each other. This is the two-pointer technique: on a sorted list, one pointer starts at each end, the program adds the two items, and then moves only the pointer that fixes the total. If the total is too small, the left pointer moves up. If it is too big, the right pointer moves down.

๐Ÿ“ Sorted rowโ†’๐Ÿ‘ˆ๐Ÿ‘‰ Pointers at both endsโ†’โž• Add the pairโ†’๐Ÿ”€ Move one pointer
Challenge 1 of 4Set up the pointers
1

Set up the hunt

Tap the steps in the order a program uses them to start a two-pointer hunt.

SHELL WEIGHTS ยท SORTED LIGHT โ†’ HEAVY ยท TARGET 20
TARGET20
SHELLS8

๐ŸŒŸ What you learned

Come back tomorrow for another advanced visual coding adventure! โœจ