### Question:
CycleDetectionByHashing { public static <T> CycleDetectionResult<T> detectCycle(Node<T> head) { if (head == null) { return new CycleDetectionResult<>(false, null); } Set<Node<T>> set = new HashSet<>(); Node<T> node = head; while (node != null) { if (set.contains(node)) { return new CycleDetectionResult<>(true, node); } set.add(node); node = node.next; } return new CycleDetectionResult<>(false, null); }  static CycleDetectionResult<T> detectCycle(Node<T> head);  }### Answer:
@Test public void givenList_detectLoop() { Assert.assertEquals(cycleExists, CycleDetectionByHashing.detectCycle(head).cycleExists); }