Company: Legalzoom Sde intern On-campus_18may
Difficulty: easy
Remaining Leaves It is a windy day and fallen leaves cover the garden. The garden is a grid height squares high and width squares wide. The top-left square is (0, 0) , where the first coordinate is the row and the second is the column ; rows increase downward and columns increase rightward. Each square holds a non-negative number of leaves. The wind arrives as a series of gusts, given by a string winds made of the characters U (up), D (down), L (left) and R (right). One gust slides every leaf in the garden exactly one square in that direction, all at the same time. A leaf pushed past an edge of the garden is blown away for good — it never comes back, even if a later gust blows the other way. The gusts are applied one after another, in the order they appear in winds . Report how many leaves are still in the garden once the last gust has passed. Input Format Line 1: the integer width . Line 2: the integer height . Line 3: the string winds . This line is present even when there are no gus