Panda Guru LogoPanda
Guru

Google Onsite round question for L3 role

Round 3

Questions: Given are Three Arrays: A, B, C

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
Explanation: 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.

Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.