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