mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
305 B
24 lines
305 B
![]()
4 years ago
|
package solutions
|
||
|
|
||
|
//returs the node in a given position
|
||
|
func ListAt(l *NodeL, nbr int) *NodeL {
|
||
|
index := 0
|
||
|
count := 0
|
||
|
head := l
|
||
|
|
||
|
for head != nil {
|
||
|
index++
|
||
|
head = head.Next
|
||
|
}
|
||
|
if nbr <= index {
|
||
|
for l != nil {
|
||
|
if count == nbr {
|
||
|
return l
|
||
|
}
|
||
|
count++
|
||
|
l = l.Next
|
||
|
}
|
||
|
}
|
||
|
return nil
|
||
|
}
|