Cyberhaven interview question

Small code optimization challenge on Engineering screening.