+ 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

6th Jun 2019, 3:29 PM
Tzion
Tzion - avatar
7 Respuestas
0
your code is checking to see if the array has a duplicate value anywhere in the array, starting at i+1.
6th Jun 2019, 3:57 PM
koala 🐨
koala 🐨 - avatar
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
6th Jun 2019, 4:02 PM
koala 🐨
koala 🐨 - avatar
0
koala 🐨 but ur output is only 44, 33 is also a duplicate value
6th Jun 2019, 11:50 PM
Tzion
Tzion - avatar
0
Rael no the answer is 44. arent you looking for values that are NEXT to eachother?
6th Jun 2019, 11:57 PM
koala 🐨
koala 🐨 - avatar
0
koala 🐨 oh not,im looking the value which got same in the array
6th Jun 2019, 11:58 PM
Tzion
Tzion - avatar
0
Rael then ur code is good
7th Jun 2019, 12:07 AM
koala 🐨
koala 🐨 - avatar
0
koala 🐨 i dont know how it work,i just type it and accidentally got the answer lol
7th Jun 2019, 12:26 AM
Tzion
Tzion - avatar