Ripple Interview Question

Leetcode problem of medium difficulty range