diff --git a/DuplicateElements.java b/DuplicateElements.java new file mode 100644 index 0000000..59027c4 --- /dev/null +++ b/DuplicateElements.java @@ -0,0 +1,19 @@ +class Main { + + public static void main(String args[]) + { + int numRay[] = { 0, 4, 3, 2, 7, 8, 2, 3, 1 }; + + for (int i = 0; i < numRay.length; i++) { + numRay[numRay[i] % numRay.length] + = numRay[numRay[i] % numRay.length] + + numRay.length; + } + System.out.println("The repeating elements are : "); + for (int i = 0; i < numRay.length; i++) { + if (numRay[i] >= numRay.length * 2) { + System.out.println(i + " "); + } + } + } +}