Company: Uber
Difficulty: medium
Spaceship Data Segments 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 defines a byte range in the form of a two-dimensional array segments . For each segment segments[i] , the range is given in an array of two 64-bit integers: segments[i][0] is the index of the first byte in the i th segment 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. Input Format array.array.integer64 segments Constraints Execution time limit: 3 seconds (java) Memory limit: 1 GB Examples Example 1: Input: segments = [[1, 1], [2, 2], [3, 3]] Output: [1, 2, 3] The first segment only contains the byte 1, so the total