MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / CheckRangeFromIndex

Method CheckRangeFromIndex

structure/linkedlist/singlylinkedlist.go:163–172  ·  view source on GitHub ↗
(left, right int)

Source from the content-addressed store, hash-verified

161 return nil
162}
163func (ll *Singly[T]) CheckRangeFromIndex(left, right int) error {
164 if left > right {
165 return errors.New("left boundary must smaller than right")
166 } else if left < 1 {
167 return errors.New("left boundary starts from the first node")
168 } else if right > ll.length {
169 return errors.New("right boundary cannot be greater than the length of the linked list")
170 }
171 return nil
172}
173
174// Display prints out the elements of the list.
175func (ll *Singly[T]) Display() {

Callers 1

ReversePartitionMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected