Cadence Sound interview question

Q: Same as Leetcode #283