Created
September 3, 2019 15:38
-
-
Save parzibyte/28ae189756ed9db6f4c013dcdfbc29e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cuenta cuántas veces aparece el valor y devuelve true si | |
// aparece exactamente una vez | |
public static boolean esValorUnico(int valor, int[] arreglo) { | |
int contador = 0; | |
for (int x = 0; x < arreglo.length; x++) { | |
if (arreglo[x] == valor) | |
contador++; | |
} | |
return contador == 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment