Given a singly linked list of integers. The task is to check if each element in the linked list is present in a pair i.e. all elements occur even no. of times.
Input: 1 -> 2 -> 3 -> 3 -> 1 -> 2 Output: Yes Input: 10 -> 20 -> 30 -> 20 Output: No
- Initialise a temp node pointing to head.
- Take a variable to calculate XOR of all elements.
- Start traversing linked list and keep calculating the XOR with node->data.
- Return true if XOR is 0, else return false.
Below is the implementation of above approach:
- Check if a pair with given product exists in Linked list
- Linked List Pair Sum
- Check if a linked list is Circular Linked List
- Partitioning a linked list around a given value and If we don't care about making the elements of the list "stable"
- Reverse even elements in a Linked List
- Reverse first K elements of given linked list
- Check whether the length of given linked list is Even or Odd
- Sum of smaller elements of nodes in a linked list
- Pairwise swap elements of a given linked list
- Find unique elements in linked list
- Check linked list with a loop is palindrome or not
- Check if a Linked List is Pairwise Sorted
- Insert N elements in a Linked List one after other at middle position
- Count minimum frequency elements in a linked list
- Double elements and append zeros in linked list
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.