feat: tuesday
This commit is contained in:
19
pkg/reverse_linked_list/main.go
Normal file
19
pkg/reverse_linked_list/main.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package reverse_linked_list
|
||||
|
||||
type ListNode struct {
|
||||
Val int
|
||||
Next *ListNode
|
||||
}
|
||||
|
||||
func ReverseList(head *ListNode) *ListNode {
|
||||
var reversed *ListNode = nil
|
||||
current := head
|
||||
|
||||
for current != nil {
|
||||
next := current.Next
|
||||
current.Next = reversed
|
||||
reversed, current = current, next
|
||||
}
|
||||
|
||||
return reversed
|
||||
}
|
||||
Reference in New Issue
Block a user