Missing from my answer above corrections:
- while( i max)
Run time complexity is as the first poster stated, @ O(n) because it runs through the array only ones, "N" amount of times. We also save space by taking the array by reference, instead of creating a new value for the function in case of 2 things:
1. It's scaled to size. Since Google uses and focuses a lot on scalability, we need to worry about what happens if we're given a larger array from the get go. A million numbers perhaps?
2. Its performance will adequately not be affect TOO harshly at run time due to the reference variable if function is called multiple times. We can call this a "helper" function of sorts in another global context scope.