Once you stop learning, you start dying
If all numbers repeated except one:
Use XOR operator
public class progprac { public static void main(String[] args) { int[] arr = {2, 3, 2, 4, 4}; int result=0; for(int num : arr) { result = result ^ num; } System.out.println("Result="+result); }}
Please comment below to feedback or ask questions.
No comments:
Post a Comment
Please comment below to feedback or ask questions.