Skip to content

Instantly share code, notes, and snippets.

@thmain
Last active May 25, 2018 03:46
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 thmain/85bc727ab69d481debc19ea84598f8d5 to your computer and use it in GitHub Desktop.
Save thmain/85bc727ab69d481debc19ea84598f8d5 to your computer and use it in GitHub Desktop.
import java.util.*;
public class TwoRepeatingSorting {
public static void twoRepeating(int [] A){
Arrays.sort(A);
System.out.print("Repeated Elements are: ");
for (int i = 0; i <A.length-1 ; i++) {
if(A[i]==A[i+1])
System.out.print(A[i] + " ");
}
}
public static void main(String[] args) {
int [] A = {1,4,5,6,3,2,5,2};
twoRepeating(A);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment