It says run time limit exceeded. I'm new to python and coding. Does my code have run time n~2?
def totalHammingDistance(self, nums):
:type nums: List[int]
for i in range (0,len(nums)-1):
for j in range (i,len(nums)-1):
n^2 run time indeed...if you consider the time spent on count function, it would be more than that
Thank you! So does the Time Limit Exceeded message mean it's not working code? Or it means it's just bad implementation that using too much resource so fail the grading. Sorry I'm new to coding, still don't have a clue.
@kittensing The time limit is put to block algorithms that are not good enough.Generally, your code may exceed the limit if the standard method is way better than yours or there is an endless loop in code. In this case, your implementation is fine, but the method needs to be improved :) I am newbee too.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.