Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created September 3, 2019 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/28ae189756ed9db6f4c013dcdfbc29e1 to your computer and use it in GitHub Desktop.
Save parzibyte/28ae189756ed9db6f4c013dcdfbc29e1 to your computer and use it in GitHub Desktop.
// 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