What’s the Issue with my code
4 test case failing
n=int(input())
li=[int(ele) for ele in input().strip().split()]
def next_index(li,i):
return (i+li[i]+len(li))%len(li)
def circular_check(li):
for i in range(len(li)):
slow=i
fast=i
if li[i]==0:
continue
while (li[slow]*li[next_index(li,slow)]>0) and (li[fast]*li[next_index(li,fast)]>0) and (li[fast]*li[next_index(li,next_index(li,fast))]>0):
slow=next_index(li,slow)
fast=next_index(li,next_index(li,fast))
if slow==fast:
if slow==next_index(li,slow):
break
return True
slow=i
val=li[slow]
while (val*li[slow]>0):
x=slow
slow=next_index(li,slow)
li[x]=0
return False
if circular_check(li):
print(1)
else:
print(0)
Have replied to you on chat, do see it.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
where ?
i can’t find that
Check chat, you will see my message.
Hello @ritvikagrawal1, don’t worry I will help you out. First of all, pls let me know the ques. Which ques is this ??