Company: Visa_30_Dec
Difficulty: medium
Longest Contiguous Houses Description You are monitoring the building density in a district of houses, which is represented as a number line. Initially, the district is empty. You are given an array of integers queries , where each element represents the location of a new house to be built. The houses are built in the order they appear in the array. After each house is built, you need to determine the length of the longest segment of contiguous houses. A contiguous segment is a sequence of houses at locations x, x+1, x+2, ..., y . Return an array of integers, where the i -th element is the length of the longest contiguous segment after the first i+1 houses have been built. Note: It is guaranteed that all house locations in queries are unique. It is also guaranteed that you will not be asked to build a house at a location that already has houses on both adjacent positions (i.e., at location - 1 and location + 1 ). This simplifies the problem by ensuring you never merge two previously se