Linked List Cycle Solutions in GoNumber 141Difficulty EasyAcceptance 41.2%Link LeetCodeOther languages C++SolutionsGo solution by halfrost/LeetCode-Gopackage leetcode import ( "github.com/halfrost/LeetCode-Go/structures") // ListNode definetype ListNode = structures.ListNode /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ func hasCycle(head *ListNode) bool { fast := head slow := head for slow != nil && fast != nil && fast.Next != nil { fast = fast.Next.Next slow = slow.Next if fast == slow { return true } } return false}package leetcode import ( "github.com/halfrost/LeetCode-Go/structures" ) // ListNode define type ListNode = structures.ListNode /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ func hasCycle(head *ListNode) bool { fast := head slow := head for slow != nil && fast != nil && fast.Next != nil { fast = fast.Next.Next slow = slow.Next if fast == slow { return true } } return false }