Google L4 Phone Screening Round
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2025-03-29Added By Anonymous
Source: Link
🧭 Experience: unknown
✅ Outcome: unknown
💰 Compensation: unknown
📍 Location: unknown
🏢 Company: Google
🎓 Education: unknown
🎁 Benefits: unknown
📅 Offer Date: unknown
# Nearest Value Replacement You are given an array A of length N, a starting index cur, and a distance D. Your task is to iteratively update the array A starting from index cur. At each step, replace A[cur] with A[cur] + 1, then find the nearest index (left or right, within distance D) where this new value exists in the array. If multiple indices exist at the same distance, choose the leftmost index. If no such index exists within distance D, keep the value in the same index and stop updating. Example 1: A = [1, 3, 2, 3, 4, 5, 2] cur = 2 D = 2 Output: [1, 3, 3, 3, 4, 5, 2]
✅ Outcome: unknown
💰 Compensation: unknown
📍 Location: unknown
🏢 Company: Google
🎓 Education: unknown
🎁 Benefits: unknown
📅 Offer Date: unknown
# Nearest Value Replacement You are given an array A of length N, a starting index cur, and a distance D. Your task is to iteratively update the array A starting from index cur. At each step, replace A[cur] with A[cur] + 1, then find the nearest index (left or right, within distance D) where this new value exists in the array. If multiple indices exist at the same distance, choose the leftmost index. If no such index exists within distance D, keep the value in the same index and stop updating. Example 1: A = [1, 3, 2, 3, 4, 5, 2] cur = 2 D = 2 Output: [1, 3, 3, 3, 4, 5, 2]