• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to secondary sidebar

GoHired

Interview Questions asked in Google, Microsoft, Amazon

Join WeekEnd Online Batch from 4-April-2020 on How to Crack Coding Interview in Just 10 Weeks : Fees just 20,000 INR

  • Home
  • Best Java Books
  • Algorithm
  • Internship
  • Certificates
  • About Us
  • Contact Us
  • Privacy Policy
  • Array
  • Stack
  • Queue
  • LinkedList
  • DP
  • Strings
  • Tree
  • Mathametical
  • Puzzles
  • Graph

Reversal of LinkedList

February 20, 2014 by Dhaval Dave

Reversal of linked list simplified With Three Pointer Without Recursion

/* Link list node */
struct node
{
    int data;
    struct node* next;
};
 
/* Function to reverse the linked list */
static void reverse(struct node** head_ref)
{
    struct node* prev   = NULL;
    struct node* current = *head_ref;
    struct node* next;
    while (current != NULL)
    {
        next  = current->next;  
        current->next = prev;   
        prev = current;
        current = next;
    }
    *head_ref = prev;
} 
 
static void reverse(struct node** head_ref)
{
    struct node* prev   = NULL;
    struct node* current = *head_ref;
    struct node* next;
    while (current != NULL)
    {
        next  = current->next;  
        current->next = prev;   
        prev = current;
        current = next;
    }
    *head_ref = prev;
} 

 

Similar Articles

Filed Under: problem Tagged With: Linked List

Reader Interactions

Primary Sidebar

Join WeekEnd Online/Offline Batch from 4-April-2020 on How to Crack Coding Interview in Just 10 Weeks : Fees just 20,000 INR

Join WeekEnd Online/Offline Batch from 4-April-2020

WhatsApp us

Secondary Sidebar

Custom Search

  • How I cracked AMAZON
  • LeetCode
  • Adobe
  • Amazon
  • Facebook
  • Microsoft
  • Hacker Earth
  • CSE Interview

Top Rated Questions

Longest Increasing Subsequence

building with N steps, we can take 1,2,3 steps calculate number of ways to reach at top of building

DFS (Depth First Search)

Flipkart SDET Interview Experience

Printing intermediate Integers between one element & next element of array

VMWare SDEII Interview

Trie Dictionary

Maximum sum contiguous subarray of an Array

Implement LRU Cache

Printing Longest Common Subsequence

Binary Tree Isomorphic to each other

Common Ancestor in a Binary Tree or Binary Search Tree

Print all nodes that are at distance k from a leaf node

Advanced SQL Injection

C++ OOPs Part1

Check if an array has duplicate numbers in O(n) time and O(1) space

Edit Distance ( Dynamic Programming )

Find Nearest Minimum number in left side in O(n)

Serialise Deserialise N-ary Tree

C++ OOPs Part2

Difference between a LinkedList and a Binary Search Tree BST

Amazon Interview On-Campus For Internship – 1

Find the kth number with prime factors 3, 5 and 7

Puzzle : 100 doors in a row Visit and Toggle the door. What state the door will be after nth pass ?

Fibonacci Hashing & Fastest Hashtable

Find Percentage of Words matching in Two Strings

Test Cases for Round Function

Find two non repeating elements in an array of repeating elements

Find Pythagorean Triplets in an array in O(N)

Stickler thief

Copyright © 2026 · Genesis Framework · WordPress · Log in