javascript get minimum value in array
// Getting min value
var arr = [5,1,9,5,7];
var min = Math.min(...arr);
console.log(min); // 1
// Getting max value
var arr = [5,1,9,5,7];
var min = Math.max(...arr);
console.log(min); // 9
javascript get minimum value in array
// Getting min value
var arr = [5,1,9,5,7];
var min = Math.min(...arr);
console.log(min); // 1
// Getting max value
var arr = [5,1,9,5,7];
var min = Math.max(...arr);
console.log(min); // 9
Find Minimum array
Array -- Find Minimum
Write a method that can find the maximum number from an int Array
Solution 1:
public static void main(String[] args) {
int[] arr = new int[]{2,4,6,8,20};
System.out.println(maxValue(arr));
public static int maxValue( int[] n ) {
int min = Integer.MAX_VALUE;
for(int each: n)
if(each < min)
min = each;
return min;
}
Solution 2:
public static int maxValue( int[] n ) {
Arrays.sort( n );
return n [ 0 ];
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us