You are viewing a single comment's thread. Return to all comments →
Would you please give me some feedback, I would highly appreciate it! Thanks in advance.
n = int(input().strip()) lst = sorted((int(x) for x in input().split()), key=lambda x: -x) def StickCuts(lst): while lst: print(len(lst)) lo = lst[-1] cuts = 0 for i in range(len(lst)): if lst[i] == lo: if i == 0: return else: lst = lst[:i] break else: lst[i] -= lo cuts += 1 StickCuts(lst)
Also, I am a little confused of what the time complexity of my code is. I would say it's O(n) - but I am not sure - do you agree?
Seems like cookies are disabled on this browser, please enable them to open this website
Cut the sticks
You are viewing a single comment's thread. Return to all comments →
Would you please give me some feedback, I would highly appreciate it! Thanks in advance.
Also, I am a little confused of what the time complexity of my code is. I would say it's O(n) - but I am not sure - do you agree?