Today I had my OA round of amazon it had 2 Coding Questions ( 90 min ).
explanation: for index (0,0) the difference is diff = {abs(1 - 1)}, diff < k so that is the first subarray.
for index (0,1) the difference is diff = {abs(1 - 3)}, diff < k so that is the second subarray.
for index (1,1) the difference is diff = {abs(3 - 3)}, diff < k so that is the third subarray.
for index (1,2) the difference is diff = {abs(3 - 5)}, diff < k so that is the fourth subarray.
for index (2,2) the difference is diff = {abs(5 - 5)}, diff < k so that is the fifth subarray.
But for index (0,2) the difference is diff = {abs(1 - 5)}, diff > k so that is NOT a subarray.
The total amount of subarray is 5