Count Equal Reversal-Difference Pairs
Updated
Problem statement
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[]) → longExamples
Example 1
numbers = [42,24]return = 2Both 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 = 2The values have different reversal differences, so only their two self-pairs qualify.
Constraints
0 <= numbers.length <= 1000000 <= 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