Intern — Middle
Finding the index of the element with the maximum absolute value
livecode
Task condition
Create a function max_abs_index() that takes one parameter: • nums — a non-empty array of integers (array size ≤ 10³). The function should return the position (index) of the element in the array nums that has the largest absolute value.
Example 1: Input: print(max_abs_index([1, 2, 10, -100, 0, -45, 99])) Output: 3
Example 2: Input: print(max_abs_index([1, 2, 10, 100, 0, 78, 1000])) Output: 6