MCPcopy Create free account
hub / github.com/VanjaRo/LeetCode / recursiveBackCounterDelete

Function recursiveBackCounterDelete

tasks/19.go:22–38  ·  view source on GitHub ↗

0 – found -1 – delete next

(head *ListNode, n int)

Source from the content-addressed store, hash-verified

20// 0 – found
21// -1 – delete next
22func recursiveBackCounterDelete(head *ListNode, n int) int {
23 if head == nil {
24 return 1
25 }
26 ret := recursiveBackCounterDelete(head.Next, n)
27 if ret == 0 {
28 return 0
29 }
30 if ret == -1 {
31 head.Next = head.Next.Next
32 return 0
33 }
34 if ret == n {
35 return -1
36 }
37 return ret++
38}
39

Callers 1

removeNthFromEndFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected