()
| 187 | } |
| 188 | |
| 189 | public boolean checkPalindrome() { |
| 190 | if(head == null || head.next == null) { |
| 191 | return true; |
| 192 | } |
| 193 | //find middle |
| 194 | Node mid = findMidNode(head); |
| 195 | |
| 196 | //Reverse 2nd half |
| 197 | Node curr = mid; |
| 198 | Node prev = null; |
| 199 | while(curr != null) { |
| 200 | Node next = curr.next; |
| 201 | curr.next = prev; |
| 202 | prev = curr; |
| 203 | curr = next; |
| 204 | } |
| 205 | Node right = prev; |
| 206 | Node left = head; |
| 207 | //check if equal |
| 208 | while(right != null) { |
| 209 | if(left.data != right.data) { |
| 210 | return false; |
| 211 | } |
| 212 | left = left.next; |
| 213 | right = right.next; |
| 214 | } |
| 215 | return true; |
| 216 | } |
| 217 | |
| 218 | public boolean isCycle() { |
| 219 | Node slow = head; |
nothing calls this directly
no test coverage detected