Stacy numbers

  • + 0 comments

    [lenth,que]=input().split(" "); lenth=int(lenth); que=int(que); num=input(); ans=[]; for i in range(0,lenth): if int(num[i])==0: ans.append(int(num[i])); continue; for j in range(i+1,lenth+1): ans.append(int(num[i]+num[i+1:j])); ans.sort(); for i in range(que): print((ans[int(input())-1])%(10**9+7));

    Can you tell me what is wrong in the code? Test case 6 onwards this code is not working. It is failing due to time out.