FastPrepLongest Contiguous Houses After Each Build
Problems/Longest Contiguous Houses After Each Build

Longest Contiguous Houses After Each Build

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Three ZipRecruiter new-grad OA reports describe distinct house positions in build order and the longest contiguous occupied segment after each build. We supplied limits and a function signature.

Initially, no integer position contains a house. The distinct values in queries give house positions in build order.

After every build, return the length of the longest contiguous run of occupied integer positions.

Function

longestHouseSegments(queries: int[]) → int[]

Examples

Example 1

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

The longest occupied segment grows from {2}, to {1,2}, to {1,2,3}.

Example 2

queries = [1,3,0,4]return = [1,1,2,2]

The final segments are {0,1} and {3,4}, both of length two.

Constraints

  • 1 <= queries.length <= 100000
  • -1000000000 <= queries[i] <= 1000000000
  • All positions are distinct.

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 Contiguous ReplacementsAmazon · OA
  • Neighboring House GroupsAtlassian · OAAtlassian interview questions
  • Group Linked Merchant RecordsStripe · PHONE SCREENStripe interview questions
  • Accounts MergeOracle · ONSITE INTERVIEWOracle interview questions
  • Bank Accounts with Balance HistoryMeta · OAMeta interview questions
  • 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

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[] longestHouseSegments(int[] queries) {
        // Write your code here.
    }

}
Checking account…