MCPcopy Index your code
hub / github.com/careercup/ctci / main

Method main

java/Chapter 2/Question2_7/QuestionB.java:36–56  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

34 }
35
36 public static void main(String[] args) {
37 int length = 9;
38 LinkedListNode[] nodes = new LinkedListNode[length];
39 for (int i = 0; i < length; i++) {
40 nodes[i] = new LinkedListNode(i >= length / 2 ? length - i - 1 : i, null, null);
41 }
42
43 for (int i = 0; i < length; i++) {
44 if (i < length - 1) {
45 nodes[i].setNext(nodes[i + 1]);
46 }
47 if (i > 0) {
48 nodes[i].setPrevious(nodes[i - 1]);
49 }
50 }
51 //nodes[length - 2].data = 9; // Uncomment to ruin palindrome
52
53 LinkedListNode head = nodes[0];
54 System.out.println(head.printForward());
55 System.out.println(isPalindrome(head));
56 }
57
58}

Callers

nothing calls this directly

Calls 4

printForwardMethod · 0.95
isPalindromeMethod · 0.95
setPreviousMethod · 0.80
setNextMethod · 0.45

Tested by

no test coverage detected