Implement a function to detect a cycle in a singly linked list and explain the space complexity of your approach.