NVIDIA interview question

Modified leetcode medium question on HackerRank