* Determine whether the values in an array are continuous and adjacent
* The following conditions are met:
* 1.0 is an exception. 0 can be repeatedly displayed. Any character can be wildly assigned.
* 2. The same values will not appear repeatedly
* 3. The array can be out of order
* When the array does not contain 0, the maximum value is satisfied - the minimum value = n (array length) -1
* When the array array contains 0, satisfy the maximum value - minimum value <n (array length) -1
* So, when the maximum value - minimum value >n (array length) -1, it must not be a continuous adjacent array
package datastruct.usearray;public class JudgeAdjacent { private static boolean judege(int a[]) { int min=Integer.MAX_VALUE; int max=Integer.MIN_VALUE; for (int i = 0; i < a.length; i++) { if (a[i]!=0) { if (min>a[i]) {min=a[i];} if (max<a target="_blank">a.length-1) {return false;}else {return true;} } public static void main(String[] args) { int a[]={8,5,0,10,6,7,0,0};if (judege(a)) {System.out.println("The array is adjacent!");}else {System.out.println("The array is not adjacent!");}}}</a>The above java method to determine whether the values in an array are continuous and adjacent is all the content I have shared with you. I hope you can give you a reference and I hope you can support Wulin.com more.