Back to course home
0% completed
Vote For New Content
What is the time complexity for the JS solution? Wouldn't it just be O(n) ? Arr...
Salah Osman
Jan 14, 2023
What is the time complexity for the JS solution? Wouldn't it just be O(n) ?
Arrays dynamically resize in javascript unlike in Java, pushing and popping from the tail is O(1). The length of array can be modified at run time (when necessary).
Or am I offtrack?
0
0
Comments
Comments
Design Gurus3 years ago
It will still take O(n^2).
We have to clone an array, which will require traversing the array to make a copy of each element.
The currentPath keeps changing with recursive function calls. Whenever we find our required path, we make a copy of that path and store it in ...
On this page