(Sort --> Adjacent Diff) ==>Optimal Solution 
ApproachSuppose arr[]={a,c,d,b,e,g,h,i,f,i};
Sort the element then it will look like this.
arr[]=     {a,b,c,d,e,f,g,h,i,i};CodeComplexity Analysis

Time comple
# Approach
**Suppose arr[]={a,c,d,b,e,g,h,i,f,i};**
**Sort the element then it will look like this.**
*arr[]=     {a,b,c,d,e,f,g,h,i,i};*
```[]
arr[]=     {a,b,c,d,e,f,g,h,i,i};
partition    |    (b-a)

arr[]=     {a,b,c,d,e,f,g,h,i,i};
partition      |    (c-b)

arr[]=     {a,b,c,d,e,f,g,h,i,i};
partition        |    (d-c)

arr[]=     {a,b,c,d,e,f,g,h,i,i};
partition          |    (e-d)

arr[]=     {a,b,c,d,e,f,g,h,i,i};
partition            |    (f-e)

arr[]=     {a,b,c,d,e,f,g,h,i,i};
partition              |    (g-f)

arr[]=     {a,b,c,d,e,f,g,h,i,i};
partition                |    (h-g)

arr[]=     {a,b,c,d,e,f,g,h,i,i};
partition                  |    (h-i)

arr[]=     {a,b,c,d,e,f,g,h,i,i};
partition                    |    (i-i)

take minimum from this partitions.
```
# Code
```java []
class Solution {
    private void print(int[] arr){
        for(int it:arr){
            System.out.print(it+" ");
        }
        System.out.println("");
    }
    public int findValueOfPartition(int[] nums){
        Arrays.sort(nums);
        //Uncomment if you want to understand the code better.
        //print(nums);
        int mindiff=Integer.MAX_VALUE;
        int n=nums.length;
        for(int i=0;i+1<n;i++){
            int diff=nums[i+1]-nums[i];
            if(diff<mindiff){
                mindiff=diff;
            }
        }        
        return mindiff;
    }
}
```
# Complexity Analysis
- Time complexity: $$O(nlog(n))$$

- Space complexity: $$O(1)$$

# Do Upvote⬆️⬆️⬆️.
# Keep Hustling,Keep Coding!!!
['Array', 'Sorting', 'C++', 'Java']