MathWorks Interview Question

watering flowers problem in leetcode.