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
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;
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
0
I have modified the Question.
Your second stated one it what I'm working on
0
why not i = i+2+1 ?
0
Finally obtain the correct solution with all conditions.
Done it.
Thank you for all your support and help.