Oscar Health interview question

A medium difficulty questions from leetcode