Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Getting wrong answer for buy1 get1 question although output and logic is correct

$
0
0

//This is the code in python for the same

z=input()

i=0 list=[] def find(i): dict1={} for j in i: dict1[j]=0 for j in i: dict1[j]=dict1[j]+1 cost=0 cost1=0 for i in dict1: if dict1[i]%2==0: cost=cost+(dict1[i]/2); else: cost1=cost1+(dict1[i]%2)+(dict1[i]/2) return cost+cost1

while(i<z): list.append(raw_input()) i=i+1 for i in list: cost=find(i) print cost


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>