0
I need your help guys! This code is working fine. But the execution time is more. So please help me to optimize this code.
4 odpowiedzi
+ 1
remove the first for loop as string is an array of chars.
you dont have to push chars into another array to get the last one. just reassign a pre defined variable.
s=input() #taking input string
n=int(input()) #taking frequency
a=''
for i in s:
if(s.count(i)==n):
a=i
if(a):
print(a)
else:
print(-1)
+ 1
Geek it works perfectly fine on my side. try clearing the cache of your sololearn app
0
Thanks farry. This code is way better than my code. But it is still showing time limit exceeded. I don't know what to do
0
This problem is asked in a practice contest in skillrack. In that private test cases are not passing.