SHARE
TWEET

Untitled

a guest May 19th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static void main(String[] args) {
  2.         int[] A = {3,5,6,3,3,5};
  3.         int[] B = {-1000000000,3,5,6,-1000000000};
  4.         int[] C = new int[0];
  5.  
  6.         System.out.println(solution(A));
  7.         System.out.println(solution(B));
  8.         System.out.println(solution(C));
  9.     }
  10.  
  11.     private static int solution(int[] A){
  12.         int counter = 0;
  13.         if(A.length == 1){
  14.             return 0;
  15.         }
  16.         for( int index = 0; index < A.length; index++) {
  17.             int currentToCheck = A[index];
  18.  
  19.             for (int j = 1; j < A.length; j++) {
  20.                 if (index < j && currentToCheck == A[j]) {
  21.                     counter++;
  22.                 }
  23.             }
  24.         }
  25.         return counter;
  26.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top