FastPrepPrefix Longest Consecutive-Value Runs
Problems/Prefix Longest Consecutive-Value Runs

Prefix Longest Consecutive-Value Runs

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter new-grad OA report describes processing prefix by prefix, runs of consecutive integers among the values seen, and two worked examples. We supplied how duplicates work and the limits. Our version is about 95% the same as the reported question.

Process values from left to right. For every prefix, consider the set of distinct values seen so far and find the longest run of consecutive integers in that set.

Return one run length for every prefix. Repeated values do not extend a run.

Function

prefixConsecutiveRuns(values: int[]) → int[]

Examples

Example 1

values = [2,1,3]return = [1,2,3]

Each new value extends the only consecutive component.

Example 2

values = [3,1,2]return = [1,1,3]

The final value joins two singleton components.

Constraints

  • 1 <= values.length <= 2000
  • -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

  • Bank Accounts with Balance HistoryMeta · OAMeta interview questions
  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN
  • Count Overlapping Square PairsRamp · OARamp interview questions
  • Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
  • Count Belt Sections With K Fruit Pairs (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Count Suffix Word PairsTikTok · OATikTok interview questions
  • Count Servers With No Requests in a Time WindowIBM · OAIBM interview questions
  • Find Valid SET Card TriplesSnowflake · OA · PHONE SCREENSnowflake interview questions
  • Maximum Escape Game ScoreMicrosoft · OAMicrosoft interview questions
  • Stacked Item and Category DiscountsPalantir · OAPalantir 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 int[] prefixConsecutiveRuns(int[] values) {
        // Write your code here.
    }

}
Checking account…