Compute subarray span for each element | Molocoads Interview Question