LESSON 51 / 75·2 min readFoundation

Linked list in C#

Should knowConcept lesson
01 Understand02 Recall03 Prepare

Node structure

csharp
public class ListNode {
    public int val;
    public ListNode next;
    public ListNode(int val = 0, ListNode next = null) {
        this.val = val;
        this.next = next;
    }
}

Problems to practice

  • Reverse Linked List
  • Remove Nth Node from End
  • Merge Two Sorted Lists
  • Detect Cycle
  • Middle of the Linked List
  • Intersection of Two Linked Lists

Example: reverse list

csharp
public ListNode ReverseList(ListNode head) {
    ListNode prev = null;
    ListNode curr = head;

    while (curr != null) {
        ListNode next = curr.next;
        curr.next = prev;
        prev = curr;
        curr = next;
    }

    return prev;
}

PAUSE & RECALL

Can you explain it without the notes?

Linked list in C#

Use your own words. Explain an example and one limitation before checking the explanation.

Check your explanation

Node structure

CONNECT IT TO YOUR INTERVIEW

Turn this concept into a clear answer.

Practice this concept
YOUR NEXT STEP

Keep connecting the ideas.

Next lesson: Stack and queue in .NET

Adapted from 17_DSA_DOTNET.md · “4. Linked list in C#”. Examples are study fragments; framework behavior can depend on your version.