Google E4 Telephonic Round
Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2025-06-03Added By Anonymous
Source: Link
Company: Google
Role: l4
Interview Stage: Phone Screen
Location: unknown
Year: unknown
Original Post Content:
The problem asked was to find indices i and j such that the sum of a contiguous subarray is maximized. The condition given was a[i] = a[j] where j > i. The objective was to maximize (a[i] + a[i+1] + . . . . + a[j]).
The proposed solution involved the following steps:
- Using a precomputed PrefixSum array to calculate range sums in O(1).
- Storing indexes of the same numbers in a hashmap.
- Employing a sliding window approach to iterate through the indices and find the maximum sum.