MCPcopy Create free account
hub / github.com/careercup/ctci / main

Method main

java/Chapter 2/Question2_6/Question.java:38–57  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

36 }
37
38 public static void main(String[] args) {
39 int list_length = 100;
40 int k = 10;
41
42 // Create linked list
43 LinkedListNode[] nodes = new LinkedListNode[list_length];
44 for (int i = 0; i < list_length; i++) {
45 nodes[i] = new LinkedListNode(i, null, i > 0 ? nodes[i - 1] : null);
46 }
47
48 // Create loop;
49 nodes[list_length - 1].next = nodes[list_length - k];
50
51 LinkedListNode loop = FindBeginning(nodes[0]);
52 if (loop == null) {
53 System.out.println("No Cycle.");
54 } else {
55 System.out.println(loop.data);
56 }
57 }
58
59}

Callers

nothing calls this directly

Calls 1

FindBeginningMethod · 0.95

Tested by

no test coverage detected