FastPrepHouse Segments After Removals
Problems/House Segments After Removals

House Segments After Removals

ZipRecruiter logoZipRecruiter● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter new-grad OA report describes houses in any starting order, valid named removals, and the count of maximal consecutive segments after every removal. We supplied limits and a function signature.

houses lists distinct occupied integer positions. Every value in queries names a currently existing house to remove.

After each removal, return the number of maximal contiguous runs of remaining house positions.

Function

houseSegmentsAfterRemovals(houses: int[], queries: int[]) → int[]

Examples

Example 1

houses = [1,2,4,5]queries = [2,4,1,5]return = [2,2,1,0]

Removing 2 and then 4 leaves two separated singleton segments; only one segment remains after removing 1.

Example 2

houses = [3]queries = [3]return = [0]

Removing the only house leaves no segments.

Constraints

  • 1 <= houses.length == queries.length <= 100000
  • Each house is removed exactly once.

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

  • Financial Account LedgerStripe · OA · PHONE SCREENStripe interview questions
  • Organization Reputation After Employee DeparturesHSBC · OAHSBC interview questions
  • Bank Accounts with Balance HistoryMeta · OAMeta interview questions
  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
  • Corporate Card Expense RulesRippling · OA · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Build Sessions from Unordered Events (Part 1)Scale AI · OAScale AI interview questions
  • Least Recently Used CacheMicrosoft · OA · PHONE SCREEN · ONSITE INTERVIEWMicrosoft interview questions
  • Parcel Event TrackingAirbnb · OAAirbnb interview questions
  • Process Banking OperationsVercel · OA
  • Drop Recent Duplicate MessagesC3.ai · OAC3.ai 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[] houseSegmentsAfterRemovals(int[] houses, int[] queries) {
        // Write your code here.
    }

}
Checking account…