Company: Visa fte
Difficulty: medium
Spacecraft Data Segments Analysis A team of astronauts on a spaceship is receiving important data from Earth for their research. The data is being transmitted in segments that contain specific parts of the file and each segment contains a byte range in the form of a two-dimensional array, segments . For each segment, segments[i][0] is the index of the first byte in the i th segment, and segments[i][1] is the index of the last byte in the i th segment (both indices are inclusive, 1-based). Your task is to calculate the total number of unique bytes received for the entire file after each segment is received. Keep in mind that segments can overlap with or completely replicate previous ones. Example Input: segments = [[1, 1], [2, 2], [1, 3]] Output: solution(segments) = [1, 2, 3] Let\'s analyze each segment: The first segment only contains byte 1, so the total number of unique bytes received becomes 1 after this segment. The second segment only contains byte 2, so the total becomes 2 after