Array Question 17
Question 17. Write a Program to print the position of first repeating element.
Program
class Solution { public static int firstRepeated(int[] arr, int n) { for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ if(arr[i]==arr[j]){ return i+1; } } } return -1; } } |