NVIDIA interview question

Two algorithms and 2 solutions.