Max of Array
题目:
Given an array with couple of float numbers. Return the max value of them.
分析:
Java中的max(arg1, arg2)属于java.lang.Math吧?所以用Math.max()
解法:
public class Solution {
/**
* @param A a float array
* @return a float number
*/
public float maxOfArray(float[] A) {
// Write your code here
float res = A[0];
for (int i = 0; i < A.length; i++) {
res = Math.max(A[i], res);
}
return res;
}
}