题解 | #三个数的最大乘积#
三个数的最大乘积
https://www.nowcoder.com/practice/8ae05c2913fe438b8b14f3968f64fc0b
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 最大乘积 * @param A int整型一维数组 * @return long长整型 */ public long solve (int[] A) { // write code here Arrays.sort(A); return Math.max((long)A[0] * (long)A[1] * (long)A[A.length - 1], (long)A[A.length - 3] * (long)A[A.length - 2] * (long)A[A.length - 1]); } }