Question: [get the question here]

Solution:

First things to consider:

- the resulting data structure must be able to accommodate [0, 5*10^10] at most which is approximately [0, 2^34]
- the range of a 32-bit integer is [-2^31, (2^31)-1]
- conclusively, an ‘int’ data type will not accommodate the extreme cases

Note:

Integer = 32-bits

Long int = 32-bits

Long long int = 64-bits

Time complexity of this solution: O(n)

Space complexity of this solution: O(n)

Advertisements