FastPrepCount Equal Reversal-Difference Pairs
Problems/Count Equal Reversal-Difference Pairs

Count Equal Reversal-Difference Pairs

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter new-grad OA report describes pairs with i<=j, the reversal equation, dropping leading zeros, and grouping by x-reverse(x). We supplied limits and a function signature.

Count index pairs (i,j) with i <= j such that numbers[i] + reverse(numbers[j]) == numbers[j] + reverse(numbers[i]). Decimal reversal discards leading zeros.

Function

countReversalPairs(numbers: int[]) → long

Examples

Example 1

numbers = [42,24]return = 2

Both self-pairs and the cross pair qualify because each difference is 18 or -18? The cross equation is equal only for matching differences, so only the two self-pairs qualify.

Example 2

numbers = [10,1]return = 2

The values have different reversal differences, so only their two self-pairs qualify.

Constraints

  • 0 <= numbers.length <= 100000
  • 0 <= numbers[i] <= 1000000000

More ZipRecruiter Online Assessment questions

  • Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
  • Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
  • Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
  • Minimum Changes to Draw a YOA · Seen Oct 2024
  • Apply Binary State OperationsOA · Seen Sep 2024
  • Simulate Orchard Rot SpreadOA · Seen Sep 2024
  • Compare Odd- and Even-Index SumsOA · Seen Sep 2024
  • Coordinate Removals with Column GravityOA · Seen Sep 2024
  • Lexicographically Smallest End ReversalOA · Seen Sep 2024
  • Recursively Expanded Shell Command CountsOA · Seen Sep 2024

Similar questions at other companies

  • Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
  • Count Subarrays with a Perfect-Square ProductMicrosoft · OAMicrosoft interview questions
  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
  • Get Triplet CountIBM · OAIBM interview questions
  • Count Reverse-Digit PairsVisa · OAVisa interview questions
  • Maximum Equal Parts for PrefixesAmazon · OA
  • Get Triplet CountPoint72 · OAPoint72 interview questions
  • Counting Triplets Divisible by DAT&T · OAAT&T interview questions
  • Maximum MEXAtlassian · OAAtlassian interview questions
  • Count Valid Square PairsAuxoAI · OA

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public long countReversalPairs(int[] numbers) {
        // Write your code here.
    }

}
Checking account…