I'm solving this challenge:
Given a positive integer number, you have to find the smallest good number greater than or equal to the given number. The positive integer is called good if it can be represented as a sum of distinct powers of 3 (i.e. no duplicates of powers of 3 are allowed).
The code passes all the test cases in the editor, but when submitted to online judge it is failing because of time limit exceeded. Give time limit 1 second, my code execution is taking 1.01 second
t = int(input()) while t > 0: N = int(input()) i=N while i > 0: if i % 3 == 2: N=N+1 i=N continue i //= 3 print(N) t = t - 1
5 3 46 65 89 113
3 81 81 90 117