Domanda di colloquio di NVIDIA

Time complexity of some code snippet, how to reduce the time complexity