First Adjacent Same-Parity Pair
Updated
Problem statement
Return the zero-based left index of the first adjacent pair whose two values have the same parity. Return -1 when every adjacent pair has opposite parity.
Negative odd values are treated as odd.
Function
firstSameParityPair(values: int[]) → intExamples
Example 1
values = [1,2,4,5]return = 1The first same-parity pair begins at index one.
Example 2
values = [1,2,3,4]return = -1Every adjacent pair has opposite parity.
Constraints
0 <= values.length <= 100000-1000000000 <= values[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
- Build the Task HierarchyPendo · OA
- Lowest Number in an Open RangeCapital One · OACapital One interview questions
- Missing IntervalsIBM · OAIBM interview questions
- Total Cost Against the Lowest Earlier PricePayPal · OAPayPal interview questions
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- Count Valid Square PairsAuxoAI · OA
- Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Two SumAmazon · OA · PHONE SCREEN
- Competition Winner and Runner-Up (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
- Find Words That Can Be Formed by CharactersTabaPay · OA