File tree Expand file tree Collapse file tree 1 file changed +6
-13
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Original file line number Diff line number Diff line change 55import java .util .ArrayList ;
66import java .util .List ;
77
8- /**
9- * 234. Palindrome Linked List
10- *
11- * Given a singly linked list, determine if it is a palindrome.
12-
13- Follow up:
14- Could you do it in O(n) time and O(1) space?
15- */
16-
178public class _234 {
189 public static class Solution1 {
19- /**O(n) time
10+ /**
11+ * O(n) time
2012 * O(1) space
21- * * /
13+ */
2214 public boolean isPalindrome (ListNode head ) {
2315 if (head == null ) {
2416 return true ;
@@ -56,9 +48,10 @@ private ListNode reverse(ListNode head) {
5648 }
5749
5850 public static class Solution2 {
59- /**O(n) time
51+ /**
52+ * O(n) time
6053 * O(n) space
61- * * /
54+ */
6255 public boolean isPalindrome (ListNode head ) {
6356 int len = 0 ;
6457 ListNode fast = head ;
You can’t perform that action at this time.
0 commit comments