We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
My code is failed for some test cases, It's in python.
n=int(input())
m=[]
for i in range(n):
s=input()
l=[]
length=len(s)
for i in range(1,length+1):
for j in range(length-i+1):
l.append(s[j:j+i])
m=m+l
m=set(m)
z=sorted(list(m))
for _ in range(int(input())):
k=int(input())
if k in range(len(z)+1):
print(z[k-1])
else:
print("INVALID")
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Find Strings
You are viewing a single comment's thread. Return to all comments →
My code is failed for some test cases, It's in python. n=int(input()) m=[] for i in range(n): s=input() l=[] length=len(s) for i in range(1,length+1): for j in range(length-i+1): l.append(s[j:j+i]) m=m+l
m=set(m) z=sorted(list(m)) for _ in range(int(input())): k=int(input()) if k in range(len(z)+1): print(z[k-1]) else: print("INVALID")