In the Golang Course for Grokking the Coding Interview. Even if I copy and paste the code from the Solution into the Try it Yourself code block for the Linked List Cycle challenge, it fails.
I noticed the input format for Try it Yourself and Solution seem different. Try it Yourself specifies input as an array followed by an int: [2,4,6,8,10] , 2
[1,3,5,7,9] , -1
[1,2,3,4,5] , 3
[0,2,3,5,6] , -1
[3,6,9,10,11] , 0
Whereas the Solution code just defines a few arrays, and then creates a Linked List Cycle for the even index arrays:
inputArray := [][]int {
{2, 4, 6, 8, 10, 12},
{1, 3, 5, 7, 9, 11},
{0, 1, 2, 3, 4, 6},
{3, 4, 7, 9, 11, 17},
{5, 1, 4, 9, 2, 3},
}
for i, input := range inputArray {
linkedList := new(EduLinkedList)
linkedList.CreateLinkedList(input)
if i % 2 == 0 {
linkedList.head.next.next.next.next.next.next = linkedList.head.next
}
Course: https://www.educative.io/courses/grokking-coding-interview-patterns-go
Lesson: https://www.educative.io/courses/grokking-coding-interview-patterns-go/7n9qnVQgDLr