Saturday, May 21, 2022

All Repeating Except One




package pep.Day82;

public class All_Repeating_Except_One {
public static void main(String[] args) {
int arr[] = {2, 2, 1, 3, 3, 4, 4, 7, 9, 9, 7};
int ans = 0;
for (int x :
arr) {
ans = ans ^ x;
}

System.out.println(ans);
}

} 

No comments:

Post a Comment

Diagonal Traversal

 eg.  1       2       3       4 5      6       7       8 9    10    11     12 13  14   15    16 Output: 1 6 11 16 2 7 12 3 8 4  Approach:...