GUVI
Back

Time Limit Exceeded!

Created 3 years ago
43 Views
1 Comments
BINSUP
@BINSUP
BINSUP
@BINSUPProfile is locked. Login
Given a number N, print the smallest number with sum of digits N. Input Size : 1 <= N <= 100000 Sample Testcase : INPUT 12 OUTPUT 39 For this problem I have used while loop and for larger input numbers like 81,its showing time limit exceeded.How to solve it? This is my code a=int(input()) d=0 i=1 while(1): c=[int(j) for j in str(i)] for k in range(len(c)): d=d+c[k] if(d==a): print(i) break c=[] d=0 i+=1
Comments
Please login to comment.
 
Powered by habitate.io Habitate