Scale interview question

One DSA question (easy level)