Skip to content

Commit c1bf342

Browse files
refactor 234
1 parent e85cbb5 commit c1bf342

File tree

1 file changed

+6
-13
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+6
-13
lines changed

src/main/java/com/fishercoder/solutions/_234.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,12 @@
55
import java.util.ArrayList;
66
import 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-
178
public 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;

0 commit comments

Comments
 (0)