Classify Heap Addresses from a Memory Snapshot
Updated
Problem statement
For this exercise, assume a process supplies an authoritative memory snapshot. Each row in regions is [start, end, kind] and covers integer addresses in the half-open interval [start, end). A kind of 1 marks heap memory; a kind of 0 marks stack memory.
For every value in addresses, return true exactly when it lies in a region marked as heap. Return false for stack addresses and for addresses absent from the snapshot. Address 0 represents null and is never included in a region.
The regions may arrive in any order. They do not overlap. Return the decisions in the same order as the queries.
Function
classifyHeapAddresses(regions: int[][], addresses: int[]) → boolean[]Examples
Example 1
regions = [[100,200,1],[300,400,0]]addresses = [100,199,200,350,0]return = [true,true,false,false,false]100 and 199 are inside the heap interval. Its end 200 is excluded. Address 350 is stack memory, and 0 is null.
Example 2
regions = [[50,60,0],[10,20,1]]addresses = [15,55,80]return = [true,false,false]The region order does not matter. Address 15 is heap, 55 is stack, and 80 is not listed.
Example 3
regions = []addresses = [0,5]return = [false,false]An empty snapshot contains no known heap interval, so both queries return false.
Constraints
0 <= regions.length <= 1000.- Every region has exactly
3fields. 0 <= regions[i][j] <= 1000000000.- For each region,
1 <= start < end, andkindis0or1. Regions are pairwise disjoint; touching endpoints are allowed. 0 <= addresses.length <= 1000.0 <= addresses[i] <= 1000000000.
More Squarepoint Capital Phone Screen questions
- Newton Square Root to a Guaranteed TolerancePHONE SCREEN · Seen Nov 2026
- Probability of Consecutive HeadsPHONE SCREEN · Seen Nov 2026
- Three Points in a Semicircle: Monte Carlo EstimatePHONE SCREEN · Seen Nov 2026
- Combine Two Index SequencesPHONE SCREEN · Seen Aug 2026
- Parse, Normalize, and Combine PolynomialsPHONE SCREEN · Seen Aug 2026
- Sorted Insertion SnapshotsPHONE SCREEN · Seen Aug 2026
- Strong and Weak Reference LifecyclePHONE SCREEN · Seen Aug 2026
- Target Sum Across Two Sorted ArraysPHONE SCREEN · Seen Aug 2026
- Fixed Worker Pool with a Shared QueuePHONE SCREEN · Seen Nov 2025
- String Copy and Move LifecyclePHONE SCREEN · Seen Nov 2025
Similar questions at other companies
- Batch Point-in-Range QueriesGoogle · PHONE SCREENGoogle interview questions
- Maximum Profit in Job SchedulingAmazon · PHONE SCREEN
- Maximum Interactive Team SizeMicrosoft · OAMicrosoft interview questions
- Maximum Team SizeExpedia · OAExpedia interview questions
- Merge Overlapping IntervalsAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
- Peak Chat Load Across AgentsCresta · PHONE SCREENCresta interview questions
- Meeting Rooms IIeBay · PHONE SCREENeBay interview questions
- Meeting Rooms IIByteDance · PHONE SCREENByteDance interview questions
- Majority Labels over Audio IntervalsNooks · PHONE SCREEN
- Meeting Rooms IIUber · PHONE SCREENUber interview questions