From 6181b10d6949a24091ddf9b26caf6d3c34fd7f5f Mon Sep 17 00:00:00 2001 From: priyagupta20044 <121642923+priyagupta20044@users.noreply.github.com> Date: Sat, 27 Jan 2024 14:01:37 +0530 Subject: [PATCH] Create priyagupta20044--c.md --- .../priyagupta20044--c.md | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Day-18/q3: Palindrome Linked List/priyagupta20044--c.md diff --git a/Day-18/q3: Palindrome Linked List/priyagupta20044--c.md b/Day-18/q3: Palindrome Linked List/priyagupta20044--c.md new file mode 100644 index 00000000..fc92110d --- /dev/null +++ b/Day-18/q3: Palindrome Linked List/priyagupta20044--c.md @@ -0,0 +1,27 @@ +/** + * Definition for singly-linked list. + * struct ListNode { + * int val; + * ListNode *next; + * ListNode() : val(0), next(nullptr) {} + * ListNode(int x) : val(x), next(nullptr) {} + * ListNode(int x, ListNode *next) : val(x), next(next) {} + * }; + */ +class Solution { +public: + bool isPalindrome(ListNode* head) { + vectorvec; + ListNode* temp = head; + while (temp!=nullptr){ + vec.push_back(temp->val); + temp=temp->next ; + } + for (int i =0 ;i