Google E4 Telephonic Round

1820
Jun 03, 2025

Find i and j such that sum of Contiguous array is maximised.

a[i] = a[j] where j > i
Maximise (a[i] + a[i+1] + . . . . + a[j])

Solution:
Precomputed PrefixSum array to calculate range sums in O(1)
Stored same number indexes in a hashmap
Used sliding window approach to move through the indices and find

Comments (8)