javascript function 2c for loops 2c linear time complexity

Solutions on MaxInterview for javascript function 2c for loops 2c linear time complexity by the best coders in the world

showing results for - "javascript function 2c for loops 2c linear time complexity"
Carlos
20 Jul 2017
1
2function crossAdd(input) {
3    var answer = [];
4    for (var i = 0; i < input.length; i++) {
5        var goingUp = input[i];
6        var goingDown = input[input.length-1-i];
7        answer.push(goingUp + goingDown);
8    }
9    return answer;
10}
11// O(N) time complexity
12
13                    
similar questions