Skyscanner interview question

Two medium difficulty DSA questions