FastPrepRoot Mean Square Error

Root Mean Square Error

Waabi logoWaabi● EasyFULLTIMEPHONE SCREEN
Learn

Problem statement

Given equal-length arrays of predicted and actual integer values, compute the root mean square error: the square root of the mean of the squared pairwise differences. Return the result rounded to exactly six digits after the decimal point.

Function

rootMeanSquareError(predicted: int[], actual: int[]) → String

Examples

Example 1

predicted = [1,2,3]actual = [1,2,3]return = "0.000000"

All differences are zero.

Example 2

predicted = [2,4]actual = [0,0]return = "3.162278"

The mean squared error is ten, whose square root is approximately 3.16227766.

Constraints

  • 1 <= predicted.length = actual.length <= 100000
  • |predicted[i]|, |actual[i]| <= 100000
See Waabi hiring insights
public String rootMeanSquareError(int[] predicted, int[] actual) {
  // Write your code here.
}
predicted[1,2,3]
actual[1,2,3]
expected"0.000000"
Checking account…