+ 1
Java code (Find duplicate value of array)
i was comment inside code of how i analysis this code but wrong,i need clear explanation https://code.sololearn.com/c54wNT94oXlX
7 Respostas
0
your code is checking to see if the array has a duplicate value anywhere in the array, starting at i+1.
0
here is what you want. you had a few errors,
1. you didnt finish the comment at the bottom with a */, so there was an error.
2. you shouldnt loop through the entire array again, just a simple "if arr[i] == arr[i+1]" will work to check if they are next to eachother.
3. the code structure made me v uncomfortable but thats ok 😂
be sure to read the comment I left below yours
https://code.sololearn.com/cIjyicOP8iw6/?ref=app
0
koala 🐨 but ur output is only 44, 33 is also a duplicate value
0
Rael no the answer is 44. arent you looking for values that are NEXT to eachother?
0
koala 🐨 oh not,im looking the value which got same in the array
0
Rael then ur code is good
0
koala 🐨 i dont know how it work,i just type it and accidentally got the answer lol