Scale Interview Question

One DSA question (easy level)