So, if I have a singly linked list that looks like: 2 6 7 8 9
I prompt the user to enter value for Y and X – for example 2 and 0
If element is greater than 2, 0 should be inserted in front of it.
So the final list should look like 2 0 6 0 7 0 8 0 9
I’m having trouble with properly adjusting the nodes, I have tried to traverse the list while keeping track of prev and current node, however I’m quite lost.
New contributor
DaLi777 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.