Root Mean Square Error
Reported by candidates from Waabi's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Waabi's September 2026 OA looks like an ML question, but it reduces to one loop and a format string. No tree, despite what the tag says. You get two integer arrays, you sum squared differences, divide by the length, take the square root, and print six decimals. If you've got an invite in your inbox, this is the easy one to bank. The only way to lose points is sloppy arithmetic or formatting. StealthCoder sits invisibly on your screen as a safety net in case you blank on the details mid-assessment.
The problem
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
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is that there isn't one. Walk both arrays once, accumulate (p - a)^2, divide by n, call sqrt, and format to exactly six digits after the decimal point. The pitfalls are all numeric. Differences can reach 200000, so each square hits 4e10, and summing up to 100000 of them reaches 4e15. That overflows a 32-bit int, so use a 64-bit integer or a double for the accumulator. Don't use integer division for the mean. Cast to floating point before dividing. Return a string, so use fixed-precision formatting like %.6f, not manual rounding, and make sure zero prints as 0.000000. The hinted tree tag is noise. If you freeze on the types or the formatting during the live OA, StealthCoder is the hedge that reads the problem and hands you the answer.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Root Mean Square Error cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Waabi's OA.
Waabi reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Root Mean Square Error FAQ
How hard is the Waabi Root Mean Square Error question really?+
It's easy. One pass over two arrays, a sum of squares, a divide, a square root. The difficulty is entirely in overflow and output formatting. If you can write a for loop and a format string, you can finish this in a few minutes.
What's the trick to avoiding wrong answers?+
Use a 64-bit accumulator. Squared differences can reach 4e10 each, and the sum across 100000 elements overflows 32-bit ints. Then convert to floating point before dividing by n, so you don't truncate the mean to an integer.
Why is this tagged as a tree problem?+
The tag looks wrong. Nothing in the statement involves nodes, hierarchy, or traversal. It's a plain array iteration with math. Ignore the tag and treat it as a simple array and math problem.
How do I get the six-decimal output right?+
Use your language's fixed-precision formatter, such as %.6f in C-style formatting or an equivalent. Return it as a string. Check Example 1 prints 0.000000 and Example 2 prints 3.162278, which confirms rounding and trailing zeros behave.
How do I prepare for this in 48 hours?+
Write the solution once from scratch and test both examples. Then test an edge case with n=1 and one with maximum values to confirm no overflow. Practice string formatting of floats in your chosen language, since that's where most people slip.