Back to problems

Count House Segments After Sequential Deletions

Algorithm · ByteDance · Medium

Count House Segments After Removals Medium · Topics · Company Tags · Hints Imagine a straight road where houses stand at various distinct integer positions. You are given an array houses of unique integers representing the initial locations. You also have an array removals which is a permutation of houses specifying the order in which the houses are demolished. After each demolition, compute the number of contiguous groups (clusters) of remaining houses. A cluster is a…

Checking your access…