All lessons

Stacks

7 min · Dart examples

Last-in-first-out structure for matching brackets, undo logic, and monotonic scans.

Dart · Stacks0/5 cleared

Enemy 1 of 5

A stack is like a pile of plates: you push on top and pop from the top. Dart Lists work great — add() to push, removeLast() to pop.

Classic use: walk a string of brackets and push opens; on a close, pop and check they match.

You
Bug Slime

Loading editor...

Ln 1, Col 1Spaces: 4
Sign up to fightTarget output: valid