You are viewing a single comment's thread. Return to all comments →
"if n in dic.values()" can start to take too much time if you are doing it too often. Try to store frequencies somewhere instead of searching through your array of values everytime you get a q==3.
I did what you said (when q==3, i used a list to store all the frequencies), however, still time out.