You are viewing a single comment's thread. Return to all comments →
What is the time complexity if I write the code in this way:
A = set(socks) for element in A: pairs += socks.count(element) // 2 print(pairs)
It should be O(n), but the space complexity increases since we create a space for A? Am I correct? Thanks for any suggestions.
Seems like cookies are disabled on this browser, please enable them to open this website
Sales by Match
You are viewing a single comment's thread. Return to all comments →
What is the time complexity if I write the code in this way:
It should be O(n), but the space complexity increases since we create a space for A? Am I correct? Thanks for any suggestions.