← Questions

Leaves left in a garden after wind gusts

0
OpenAICodingLast asked Sep 2026

A garden is a grid where each cell holds some number of leaves. A string of gusts (U, D, L, R) blows every remaining leaf one cell in that direction, and leaves blown off the edge are gone. Return how many leaves are left after all the gusts. Simulating the grid works for small inputs; the better answer tracks the net shift and the furthest it reached in each direction, then sums the surviving rectangle.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding