```javaclassSolution {publiclongmaximumTripletValue(int[] nums) {int n =nums.length;int[] leftMax =newint[n];int[] rightMax =newint[n];// leftMax[i] is the current max value before i indexfor (int i =1; i < n; i++) { leftMax[i] =Math.max(leftMax[i-1], nums[i-1]); }// vice versafor (int i = n-2; i >=0 ; i--) { rightMax[i] =Math.max(rightMax[i+1], nums[i+1]); }long result =0;// as nums[j] (1 to n-2, 0 is nums[i], n-1 is nums[k]) as the center to use MaxLeft, Maxright to calculatefor (int i =1; i < n-1; i++) { result =Math.max(result, (long)(leftMax[i] - nums[i])*rightMax[i]); }return result; }}```