Hi all,
I am having some problems with my code. I think I have the answer but somehow
the grader mark me wrongly. I can't think of any cases that I might have miss
out. I be glad if somebody can enlighten me. I placed the link of problem here
for easy access
https://codingcompetitions.withgoogle.com/codejam/round/00000000000000cb/00000000000079cb
def main():
for i in range(int(input())):
n = int(input())
ls = input().split(" ")
c = sol(ls,n)
print("Case #{}: {}".format(i+1, c))
def sol(ls,n):
ls1=[]
ls2=[]
i=0
while i<n:
if i%2==0:
ls1.append(ls[i])
else:
ls2.append(ls[i])
i+=1
ls1.sort()
ls2.sort()
#print(ls1,'\n',ls2)
b=0
e1,e2=0,0
for i in range(n//2):
if ls1[i]>ls2[i]:
#print(ls1[i],ls2[i])
e1 = 2*i
b+=1
break
for i in range((n-1)//2):
if ls2[i]>ls1[i+1]:
e2 = 2*(i+1)-1
b+=1
break
if b==2:
return min(e1,e2)
elif b==1: return max(e1,e2)
else: return 'OK'
main()
--
You received this message because you are subscribed to the Google Groups
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-code/720d21f7-06c6-44d9-b676-eaf76231a502%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.