FastPrepCount Paired Subarrays Reaching a Target
Problems/Count Paired Subarrays Reaching a Target

Count Paired Subarrays Reaching a Target

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter new-grad OA report describes positive arrays, one non-empty contiguous subarray from each, ordered choices, the target sum, and exact limits. We supplied a function signature.

Given positive integer arrays first and second and a positive target, choose one nonempty contiguous subarray from each array.

Return the number of ordered choices whose two subarray sums add to target.

Function

countPairedSubarrays(first: int[], second: int[], target: int) → long

Examples

Example 1

first = [1,2]second = [1,1]target = 3return = 3

A first-array sum of 1 needs a second-array sum of 2, and a first-array sum of 2 needs a second-array sum of 1. The sum two in the second array comes from one subarray, and the sum one comes from two different subarrays. That makes one choice plus two choices, three in all.

Example 2

first = [5]second = [5]target = 10return = 1

The two singleton subarrays form one choice.

Constraints

  • 1 <= first.length,second.length <= 1000
  • 1 <= value <= 1000
  • 1 <= target <= 1000000

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

  • Count Subarrays with a Perfect-Square ProductMicrosoft · OAMicrosoft interview questions
  • Count Zero-Sum FragmentsTesla · OATesla interview questions
  • Count Stable Server SubsegmentsScale AI · OAScale AI interview questions
  • Number of Unique Elements After Modifications 🍁Infosys · OAInfosys interview questions
  • Count Subarrays with Sum KIndeed · OAIndeed interview questions
  • Count Subarrays With Given XORInMobi · OAInMobi interview questions
  • Count Subarrays with Sum Divisible by KVisa · OAVisa interview questions
  • Beautiful SubarraysAtlassian · OAAtlassian interview questions
  • Find Security LevelAmazon · OA
  • Subarray Sum Equals KServiceNow · ONSITE INTERVIEWServiceNow interview questions

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 countPairedSubarrays(int[] first, int[] second, int target) {
        // Write your code here.
    }

}
Checking account…