Given a linked list having n nodes. Reverse the list using iterative approach.
Please try solving this problem before jumping on the solution
Click to learn
Subscribe for more updates
Preparing for interviews? IDeserve team is here to help.
Create your profile
Create your profile, and here is what you will get:
1: Interview practice platform.
2: Once you are ready to take the interview, IDeserve team will help you get connected to the best job opportunities.
3: Personalized mentorship from IDeserve team once your interview process has started.
Creation of profile shouldn't take more than 2 minutes.
Keep 3 pointers - prev (previous node), curr (current node) and nxt (next node). 1. Initialize prev = null, curr = null, nxt = head. 2. Set curr = nxt. 3. Move nxt to next node pointer. 4. Set curr next to prev. 5. Set prev to curr 6. Repeat steps 2-5 till next is not null. 7. Set curr as head pointer of the list.
Support us by whitelisting IDeserve in your ad-blocker.