Company: HackerRank
Difficulty: medium
Objective Autumn gusts have been sweeping through a courtyard, scattering leaves across the ground. Write a program that works out how many leaves remain in the courtyard after a sequence of wind gusts. How it works The ground is modeled as a grid height squares tall and width squares wide. The top-left square sits at (0, 0) , where the first integer is the row and the second is the column. Each grid entry gives the number of leaves currently sitting on that square. The sequence of gusts, winds , is a string made up of the characters U (up), D (down), R (right), L (left). Each gust shifts every leaf on the grid one square in that gust's direction. Leaves that get pushed past the edge of the grid blow out of the courtyard entirely. Implementation Implement the function remaining_leaves(width, height, leaves, winds) , which: accepts the integers width and height , the 2D integer array leaves , and the string winds , with: 0 < width < 20 0 < height < 20 0 <= leaves < 20