Back to course home
0% completed
Vote For New Content
Using Object.keys() for iterating increases time complexity
Ariel Davies
Jun 3, 2024
The current solution uses while(Object.keys()) which increases the time complexity from O(N) to O(N * K) where K is each key in the object that has to be added again into an array for each iteration.
The optimal solution would instead have an int as the counter which gets us back to O(N).
2
0
Comments
Comments
On this page