Developers at Amazon are building a multi-process analysis tool to analyze the computational intensity of the processes. There are n processes and the ithprocess needs process[i] computation resources for completion.
Two processes are considered to be computationally the same if their resource requirements differ by at most m.
Given the array process and an integer m, find the number of pairs of processes that are computationally the same.
Complete the function getComputationalEquivalents in the editor.
getComputationalEquivalents takes the following arguments:
int process[n]: the computational resource requirement of the processesint m: the threshold for being computationally the same
Examples
01 · Example 1
process = [7, 10, 13, 11] m = 3 return = 4

Hence, the answer is 4 :)
Constraints
More Amazon problems
- Count Promotional PeriodsOA · Seen Jun 2026
- Find Maximum Total Amount (SDE I, Fungible :)Seen Jun 2026
- Get Minimum AmountOA · Seen Jun 2026
- Find Minimum CostOA · Seen Jun 2026
- Get Smallest Base SegmentOA · Seen Jun 2026
- Select Least Resource TasksOA · Seen Jun 2026
- Product Category Group SizesPHONE SCREEN · Seen May 2026
- Count Connected ComponentsPHONE SCREEN · Seen May 2026
public int getComputationalEquivalents(int[] process, int m) {
// write your code here
}
process[7, 10, 13, 11]
m3
expected4
sign in to submit