NVIDIA interview question

Solving API Hackerrank type question