Skip to content

Commit 1af8f70

Browse files
authored
Update linked_list_reverse.js
Space and time complexities added
1 parent b23d809 commit 1af8f70

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Linked List/linked_list_reverse.js

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ var reverseList = function(head) {
2323
// Returning the head of the reversed linked list
2424
return prev;
2525
};
26+
// Time complexity - O(N)
27+
// Space complexity - O(1)
2628

2729
// Recursively
2830
var reverseList = function(head) {
@@ -41,3 +43,5 @@ var reverseList = function(head) {
4143
// Returning the head of the reversed linked list
4244
return reversedList;
4345
};
46+
// Time complexity - O(N)
47+
// Space complexity - O(N)

0 commit comments

Comments
 (0)