Skip to content

Commit f4bf113

Browse files
authored
Create 0876_Middle_of_LL.java
1 parent bb202c6 commit f4bf113

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

0876_Middle_of_LL.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Definition for singly-linked list.
3+
* public class ListNode {
4+
* int val;
5+
* ListNode next;
6+
* ListNode() {}
7+
* ListNode(int val) { this.val = val; }
8+
* ListNode(int val, ListNode next) { this.val = val; this.next = next; }
9+
* }
10+
*/
11+
12+
class Solution {
13+
public boolean isPalindrome(ListNode head) {
14+
ListNode slow = head;
15+
ListNode fast = head;
16+
17+
while(fast!=null && fast.next !=null){
18+
slow = slow.next;
19+
fast = fast.next.next;
20+
21+
}
22+
return slow;
23+
24+
25+
}
26+
}

0 commit comments

Comments
 (0)