Cyberhaven Interview Question

Small code optimization challenge on Engineering screening.