Google Onsite round question for L3 role
Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2024-12-01Added By Anonymous
Source: Link
🧭 Experience: unknown
✅ Outcome: unknown
💰 Compensation: unknown
📍 Location: unknown
🏢 Company: Google
🎓 Education: unknown
🎁 Benefits: unknown
📅 Offer Date: unknown
In the 3rd google onsite round, I was asked the question similar to below one related to arrays:
Given are Three Arrays : A, B, C
- Non-negative integers
- SORTED ARRAYS
- have the same length N
A non-negative integer D.
Find the number of triplets (i, j, k) such that, they follow these constraints:
|A[i] - B[j]| <= D
|A[i] - C[k]| <= D
|B[j] - C[k]| <= D
|max() - min()| <= D
Example :
Input: A = [1, 5, 5], B = [3, 4, 5], C = [6, 6, 8], D = 1
output: 2
Expalnation: 5,5,6 triplet from indices (2,2,0), (2,2,1), gives 2 triplets
Solve the question in O(nlogn) time complexity and O(1) space complexity.
✅ Outcome: unknown
💰 Compensation: unknown
📍 Location: unknown
🏢 Company: Google
🎓 Education: unknown
🎁 Benefits: unknown
📅 Offer Date: unknown
In the 3rd google onsite round, I was asked the question similar to below one related to arrays:
Given are Three Arrays : A, B, C
- Non-negative integers
- SORTED ARRAYS
- have the same length N
A non-negative integer D.
Find the number of triplets (i, j, k) such that, they follow these constraints:
|A[i] - B[j]| <= D
|A[i] - C[k]| <= D
|B[j] - C[k]| <= D
|max() - min()| <= D
Example :
Input: A = [1, 5, 5], B = [3, 4, 5], C = [6, 6, 8], D = 1
output: 2
Expalnation: 5,5,6 triplet from indices (2,2,0), (2,2,1), gives 2 triplets
Solve the question in O(nlogn) time complexity and O(1) space complexity.