Formlabs Interview Question

They asked me a LeetCode question, easy to medium.