(String[] args)
| 42 | } |
| 43 | |
| 44 | public static void main(String[] args) { |
| 45 | int length = 10; |
| 46 | LinkedListNode[] nodes = new LinkedListNode[length]; |
| 47 | for (int i = 0; i < length; i++) { |
| 48 | nodes[i] = new LinkedListNode(i >= length / 2 ? length - i - 1 : i, null, null); |
| 49 | } |
| 50 | |
| 51 | for (int i = 0; i < length; i++) { |
| 52 | if (i < length - 1) { |
| 53 | nodes[i].setNext(nodes[i + 1]); |
| 54 | } |
| 55 | if (i > 0) { |
| 56 | nodes[i].setPrevious(nodes[i - 1]); |
| 57 | } |
| 58 | } |
| 59 | // nodes[length - 2].data = 9; // Uncomment to ruin palindrome |
| 60 | |
| 61 | LinkedListNode head = nodes[0]; |
| 62 | System.out.println(head.printForward()); |
| 63 | Question q = new Question(); |
| 64 | System.out.println(q.isPalindrome(head)); |
| 65 | } |
| 66 | |
| 67 | } |
nothing calls this directly
no test coverage detected