Grid Dynamics Interview Question

Some technical tasks from leetcode