Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- int[] A = {3,5,6,3,3,5};
- int[] B = {-1000000000,3,5,6,-1000000000};
- int[] C = new int[0];
- System.out.println(solution(A));
- System.out.println(solution(B));
- System.out.println(solution(C));
- }
- private static int solution(int[] A){
- int counter = 0;
- if(A.length == 1){
- return 0;
- }
- for( int index = 0; index < A.length; index++) {
- int currentToCheck = A[index];
- for (int j = 1; j < A.length; j++) {
- if (index < j && currentToCheck == A[j]) {
- counter++;
- }
- }
- }
- return counter;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement