Here is the corrected code: ``` public class FindElementArray { public static void main(String[] args) { int a[] = {3, 4, 4, 3, 5, 5}; for (int i = 0; i < a.length; i++) { for (int j = i + 1; j < a.length; j++) { if (a[i] == a[j]) { System.out.println(a[i]); break; // add break to avoid duplicate prints } } } } } ``` This code will print each duplicate element only once.
this code does not work , if a number is repeated for more than 2 times, if you define a code it must be solve for all the test cases, not for your own input, if i code this in my interview, then i will not get the job, because it does not run all the testcases, i can easily search another video, but for the first time, i see the template, ican trust this video can give me the correct answer, but it is a time waste thing for me and the 2.5 k view since today(3/9/24).
Very clear explain akka👏
Super akka.. Keep going..
Very clear explanation 😍
thank you, clearly understood
Super madam....
Best teaching....
❤❤❤
Thanks a lot
Here is the corrected code:
```
public class FindElementArray {
public static void main(String[] args) {
int a[] = {3, 4, 4, 3, 5, 5};
for (int i = 0; i < a.length; i++) {
for (int j = i + 1; j < a.length; j++) {
if (a[i] == a[j]) {
System.out.println(a[i]);
break; // add break to avoid duplicate prints
}
}
}
}
}
```
This code will print each duplicate element only once.
Array and loop videos uploaded akka it's my request
But this code I run error came
this code does not work , if a number is repeated for more than 2 times, if you define a code it must be solve for all the test cases, not for your own input, if i code this in my interview, then i will not get the job, because it does not run all the testcases, i can easily search another video, but for the first time, i see the template, ican trust this video can give me the correct answer, but it is a time waste thing for me and the 2.5 k view since today(3/9/24).