My issue
I can solve it with for loop with checking indexes but that will take O(n) but I want it to solve with better way O(1) giving error? anybody?
My code
# cook your dish here
def chefAndString(s):
count=0
for i in range(0,len(s)-1,2):
if "xy" in s:
count+=1
return count
t=int(input())
while(t>0):
s=input()
print(chefAndString(s))
t-=1
Learning course: Greedy Algorithms
Problem Link: Chef and String Practice Problem in Greedy Algorithms - CodeChef