Reported October 2023
ZipRecruiterarray

Evaluate Indexed Arithmetic Equations

Reported by candidates from ZipRecruiter's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live ZipRecruiter OA. Under 2s to a working solution.
Founder's read

The ZipRecruiter OA reported in October 2023 looks like a warm-up, and that's the trap. Four aligned arrays, one operator per index, return a boolean per row. It's a plain array walk with no clever pattern. What separates a pass from a fail is division. Zero divisors, negative numbers, and non-integer quotients all break the lazy version. If you blank on the edge cases during the live assessment, StealthCoder runs invisibly on your desktop and gives you a safety net. Know the traps first, though, because they're the whole question.

The problem

The four arrays are aligned. At index i, apply operator +, -, *, or / to left[i] and right[i], and report whether the exact mathematical result equals expected[i].
Division by zero is false. Division is true only when the quotient is an integer equal to expected.

Function
evaluateEquations(left: int[], right: int[], expected: int[], operators: String[]) → boolean[]

Examples
Example 1
left = [2,5,3,8]
right = [3,2,4,2]
expected = [5,3,12,4]
operators = ["+","-","*","/"]
return = [true,true,true,true]
Each supported operation evaluates true.
Example 2
left = [1,2]
right = [1,2]
expected = [3,5]
operators = ["+","*"]
return = [false,false]
Incorrect expected values return false.

Constraints
0 <= left.length <= 100000
All arrays have equal length; integer values are in [-10000,10000].

Reported by candidates. Source: FastPrep

Pattern and pitfall

The algorithm is one loop over n indices, O(n) time and O(n) output. For +, -, and *, compute the result and compare it to expected[i]. Values stay within 10000, so the products fit in a normal int. Division is where people lose points. First, if right[i] is 0, push false before you divide. Second, don't use integer division and compare, because 7 / 2 gives 3 and could wrongly match expected 3. Check left[i] % right[i] == 0 first, then compare left[i] / right[i] to expected[i]. Negative operands work fine with that remainder check in most languages, since a zero remainder is zero regardless of sign. Also handle empty arrays by returning an empty list. An unknown operator should fall to false. StealthCoder is the hedge if you freeze mid-OA, but this one is easy to hold in your head.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Evaluate Indexed Arithmetic Equations 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 by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass ZipRecruiter's OA.

ZipRecruiter reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Evaluate Indexed Arithmetic Equations FAQ

What's the trick in the ZipRecruiter Evaluate Indexed Arithmetic Equations problem?+

Division. Check for a zero divisor first and return false. Then check that left % right equals 0 before comparing the quotient to expected. Skipping the remainder check lets truncated integer division produce false positives like 7 / 2 matching 3.

How hard is this OA really?+

Easy on algorithm, medium on carefulness. It's a single linear pass with no data structures. Candidates lose points on division by zero, truncation, and empty input, not on the main logic.

Do negative numbers cause problems with division?+

Not if you check the remainder against zero. -8 % 2 is 0 and -8 / 2 is -4, which is exact. Non-exact cases like -7 / 2 have a nonzero remainder, so you return false before the quotient matters.

What should I return for empty arrays?+

An empty boolean array. The constraints allow length 0, so your loop should simply not run and you return the empty result. Don't index into the arrays before checking length.

How do I prepare for this in 48 hours?+

Write the function once in your language of choice and test it against five cases: zero divisor, inexact division, negative operands, wrong expected values, and empty input. That covers every way this question fails. Spend the remaining time on harder array and hash map problems.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with ZipRecruiter.

OA at ZipRecruiter?
Invisible during screen share
Get it