0

Working on the Index Checker code with the specified conditions. So far i have made a code, but it doesn't work on dynamic chang

Problem Statement :- You have given a array 1,2,3,4... Nd at one place (i) it suddenly increment by 2nd element after it, then again it start incrementing by 1 how will you find this (i) position Note - Without using for loop https://code.sololearn.com/cvJ0cJBVZl89/?ref=app

21st Oct 2019, 7:42 AM
Agron
Agron - avatar
5 Respuestas
+ 2
I would try this while(i < len){ if(arr[i] == t){ //element found return i; }else{ //increment i i++; }//end if }//end while //element is not in the array return -1;
22nd Oct 2019, 12:46 AM
Denise Roßberg
Denise Roßberg - avatar
0
it is unclear what is "increment by 2nd" if it mean i+2, then solution is: return i+3; but instead you search n in array and then increment i = i+2 perhaps you want increment only i = i+1
21st Oct 2019, 5:35 PM
zemiak
0
I have modified the Question. Your second stated one it what I'm working on
21st Oct 2019, 5:40 PM
Agron
Agron - avatar
0
why not i = i+2+1 ?
21st Oct 2019, 6:27 PM
zemiak
0
Finally obtain the correct solution with all conditions. Done it. Thank you for all your support and help.
22nd Oct 2019, 3:19 PM
Agron
Agron - avatar