-
-
Save AahanSingh/bc8b735d748d1098c4de6d3879777aad to your computer and use it in GitHub Desktop.
Insert at end inplace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func InsertAtEndInPlace(head **Node, x int) { | |
tmp := Node{Next: nil, Data: x} | |
if *head == nil { | |
*head = &tmp | |
} else { | |
var p *Node | |
p = *head | |
for ; p.Next != nil; p = p.Next { | |
} | |
p.Next = &tmp | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment