• + 0 comments

    Ok! I did the same mistake and implemented the same algorithm as you did. But you see, the problem is, from the given subset, if we take a nested loop for i and j if ith value is 5: jth value is 4: we get absolute difference as 1 ( increasing count by 1) jth value is 6: we get absolute difference as 1 (increasing count by 1)

    but the absolute difference between 4 and 6 ( since both are a part of our subarray, with atleast the wrong assumption that we made), is 2. which is wrong.