NVIDIA interview question

Given an array A , find the maximum difference between an element in the array and the elements before it.

Interview Answer

Anonymous

8 Sept 2024

Traverse the array while maintaining two variables for each element: - The minimum value encountered so far (initialized to the first element). - The maximum difference observed between the current element and the minimum value.