Answers for "array find max value return index"

1

js get max value in an array

const myArray = [1, 14, 32, 7];

const maxValue = Math.max(...myArray);

console.log(maxValue); // 32
Posted by: Guest on February-01-2022
1

how to get index of max n values in an array

In [1]: import numpy as np

In [2]: arr = np.array([1, 3, 2, 4, 5])

In [3]: arr.argsort()[-3:][::-1]
Out[3]: array([4, 3, 1])
Posted by: Guest on July-04-2020

Code answers related to "array find max value return index"

Browse Popular Code Answers by Language