Skip to content

Commit 8886e7d

Browse files
committed
add description
1 parent 85b6371 commit 8886e7d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Linked List/linked_list_pallindrome.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
1+
/*
2+
Given the head of a singly linked list, return true if it is a
3+
palindrome
4+
or false otherwise.
15
6+
7+
8+
Example 1:
9+
10+
11+
Input: head = [1,2,2,1]
12+
Output: true
13+
Example 2:
14+
15+
16+
Input: head = [1,2]
17+
Output: false
18+
19+
20+
Constraints:
21+
22+
The number of nodes in the list is in the range [1, 105].
23+
0 <= Node.val <= 9
24+
25+
26+
Follow up: Could you do it in O(n) time and O(1) space?
27+
*/
228
/**
329
* Definition for singly-linked list.
430
* struct ListNode {
@@ -9,6 +35,8 @@
935
* ListNode(int x, ListNode *next) : val(x), next(next) {}
1036
* };
1137
*/
38+
39+
// TODO: Implement O(1) space
1240
class Solution {
1341
public:
1442
bool isPalindrome(ListNode* head) {

0 commit comments

Comments
 (0)