Skip to content

Commit 803a382

Browse files
committed
add time andd space complexity
1 parent c948124 commit 803a382

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Linked List/linked_list_even_or_odd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
Use a 2x pointer. Take a pointer that moves at 2x [two nodes at a time]. At the end, if the length is even,
66
then the pointer will be nil; otherwise it will point to the last node.
77
*/
8+
// Time Complexity: O(⌊n/2⌋) ≈O(n). Space Complexity: O(1).
89
package main
9-
import "fmt"
1010

1111
// has two fields [data] of type integer and [next] of type *node (holds the memory address of next node)
1212
type node struct {

0 commit comments

Comments
 (0)