MAQ Software interview question

Basic DSA very basic and easy stuff