jeudi 8 novembre 2018

Check if numbers are successive

for(int i = 0; i < aLenght; i++) {
    for(int j = 0; j < bLenght; j++) {
        if(aChars[i] == bChars[j]) {
            System.out.println(j +" == "+ i);
        }
    }
}

For instance the code above generates the following output:
3 == 0
5 == 0
4 == 1
6 == 1

Now I would like to check whether there exist successive numbers on both sides. For instance the example above would return true, because 3 == 0 and 4 == 1 are successive.

Aucun commentaire:

Enregistrer un commentaire