Pergunta de entrevista da empresa DoorDash

Two leetcode medium to hards.