We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 85b6371 commit 8886e7dCopy full SHA for 8886e7d
Linked List/linked_list_pallindrome.cpp
@@ -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.
5
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
+*/
28
/**
29
* Definition for singly-linked list.
30
* struct ListNode {
@@ -9,6 +35,8 @@
35
* ListNode(int x, ListNode *next) : val(x), next(next) {}
36
* };
37
*/
38
39
+// TODO: Implement O(1) space
40
class Solution {
41
public:
42
bool isPalindrome(ListNode* head) {
0 commit comments