Panda Guru LogoPanda
Guru

Salesforce | OA | LMTS| JULY 2024

Round 1

Questions: Write a program to find the number of pairs of elements in an array, that satisfy the below condition.

min(|a−b|,|a+b|) ≤ min(|a|,|b|)
max(|a−b|,|a+b|) ≥ max(|a|,|b|)

min(|a−b|,|a+b|) ≤ min(|a|,|b|) ≤ max(|a|,|b|) ≤ max(|a−b|,|a+b|)

Example:

[-9, 6, -5, 3]

-9 -5
-9 6
-5 3
-5 6
3 6

Constraints:

1 <= N <= 200000
-1000000000 <= a[i] <= 1000000000

Specific question not provided.

Candidate's Approach

The candidate attempted to solve the problem with an O(N^2) approach but faced timeouts on 6 test cases. They are seeking an O(N log N) solution.

Interviewer's Feedback

No feedback provided.