class Solution{ //Function to find minimum adjacent difference in a circular array. // arr[]: input array // n: size of array public static int minAdjDiff(int arr[], int n) { int min=Math.abs(arr[0]-arr[n-1]),diff; for(int i=0;i<n-1;i++) { diff=Math.abs(arr[i]-arr[i+1]); if(diff<min) min=diff; } return min; } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter