Google onsite problem
Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2024-12-22Added By Anonymous
Source: Link
Company: Google
Role: unknown
Interview Stage: Onsite
Location: unknown
Year: unknown
Original Post Content:
Given an array { 1, 7, 7, 2, 3, 7, 6, -20}. Find the longest non-decreasing contiguous sequence with substitution. We can substitute any array element with any integer such that all occurrences of 7 are replaced with 1. In this way, the new array would be { 1, 1, 1, 2, 3, 1, 6, -20}. Here, the answer would be 5 from [1, 1, 1, 2, 3]
Only one substitution is allowed.