Easy solution in java (O(n))
IntuitionJust sort the element of array and check for i and i+1 th element in array. Whicheve is minimum return that.ApproachComplexity
Time complexity:
O(n)
Sp
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Just sort the element of array and check for i and i+1 th element in array. Whicheve is minimum return that.
# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(n)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(1)
# Code
```java []
class Solution {
    public int findValueOfPartition(int[] nums) {
        Arrays.sort(nums);
        int min = Integer.MAX_VALUE;
        for(int i=0;i<nums.length-1;i++) {
          min=Math.min(min,Math.abs(nums[i]-nums[i+1]));
        }
        return min;
    }
}
```
['Sorting', 'Java']