although my code is passing sample test case,yet iam getting it as wrong answer.Can anyone tell me what is wrong with my code . My solution is refer my solution
Well, there is a small flaw in your logic, see for the case like [ 1 , 3 , 4 ] the answer is 1, but you’re only considering the differences between the first two elements which is 2.
Click to view
Instead try traversing all the adjacent pairs in the sorted array and take the minimum difference. See this for reference