def print_all_codes(n, m): def print_01_codes(current, num_digits): if num_digits == 0: print(current) else: print_01_codes('0' + current, num_digits - 1) print_01_codes('1' + current, num_digits - 1) upper_bound = 0 while True: for i in range(upper_bound): print_01_codes('', n) if upper_bound > m: break upper_bound += 1 I have tried to solve this problem for a while and the only conclusion I came up with was: O(m*2^n) I have seen the other problem that has a similar wording, but the conclusion to that problem was inconclusive. Similar problem
https://stackoverflow.com/questions/66575010/what-is-the-run-time-complexity-of-the-following-algorithm-in-terms-of-n-and-m March 11, 2021 at 08:53AM
没有评论:
发表评论