FastPrepReverse a Linked List
Problems/Reverse a Linked List

Reverse a Linked List

Capital One logoCapital One● EasyFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Five Capital One software engineer interview reports, from 2015 to 2024, list a linked-list reversal among their coding questions. They agree on the task but give no input format, limits or examples. This version uses one-way links. The function hands back the node that ends up in front, and a null input gives null. The limits are our choices.

Our version is about 90% the same as the reported questions.

The argument head is the front node of a list whose nodes link forward only, or null for a list with zero nodes. Rearrange the links so that following them from the new front visits the values from last to first.

Return the node that was last in the input. With zero nodes there is nothing to rearrange, so a null input gives null.

Function

reverseList(head: ListNode) → ListNode

Examples

Example 1

head = [6,-2,9,4]return = [4,9,-2,6]
head
6-294
→
return
49-26
Moved or new

The list starts as 6 -> -2 -> 9 -> 4. Once each of its three links points the other way, node 4 has no node in front of it, so it is the head. Reading from there gives 4 -> 9 -> -2 -> 6, and node 6 now links to null.

Example 2

head = [7,-3]return = [-3,7]
head
7-3
→
return
-37
Moved or new

With two nodes, the single link turns around. Node -3 now points to node 7, and 7 becomes the last node.

Example 3

head = []return = []
head
empty
return
empty

The head passed in is already null. No pointer exists to flip, so that same null is the answer.

Constraints

  • The number of nodes in the list is between 0 and 2000.
  • -1000 <= Node.val <= 1000

More Capital One Onsite Interview questions

  • Digit-Coded Card ValidationONSITE INTERVIEW · Seen Nov 2026
  • Sort ColorsONSITE INTERVIEW · Seen Oct 2026
  • Virtual Card Transaction ValidatorONSITE INTERVIEW · Seen Oct 2026
  • Banking System with Top ActivityONSITE INTERVIEW · Seen Sep 2026
  • Transaction Event StoreONSITE INTERVIEW · Seen Jul 2026
  • Shortest Path in an Unweighted GraphONSITE INTERVIEW · Seen Jul 2026
  • Duplicate Transactions Within 60 SecondsONSITE INTERVIEW · Seen May 2026
  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen May 2026
  • Cashback TrackerONSITE INTERVIEW · Seen Nov 2025
  • Reverse a StringOA · ONSITE INTERVIEW · Seen Oct 2025

Similar questions at other companies

  • Detect a Loop in a Linked ListEPAM · ONSITE INTERVIEWEPAM interview questions
  • Delete a Doubly Linked List Node at a PositionQualys · ONSITE INTERVIEWQualys interview questions
  • Insert After a Linked-List NodeAMD · ONSITE INTERVIEWAMD interview questions
  • Reverse a Singly Linked ListGoogle · ONSITE INTERVIEWGoogle interview questions
  • Process Singly Linked List OperationsSEDEMAC · ONSITE INTERVIEW
  • Merge Two Sorted Linked ListsZS · ONSITE INTERVIEWZS interview questions
  • Middle Node Of A Linked ListNVIDIA · ONSITE INTERVIEWNVIDIA interview questions
  • Build and Check a Palindrome Linked ListOmnissa · ONSITE INTERVIEWOmnissa interview questions
  • Reverse a Singly Linked ListGEP · ONSITE INTERVIEW
  • Merge Two Sorted Linked ListsApple · ONSITE INTERVIEWApple interview questions

Capital One interview experiences

  • Capital One Coding OA Questions: 3 Experiences
  • Capital One Experienced Engineer Power Day and OA: 6 Experiences
  • Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
  • Capital One TDP Agentic Round (AI Coding): 7 Experiences
  • Capital One SWE Power Day, Level Not Reported: 6 Experiences
  • Capital One TIP Intern OA and Power Day: 13 Experiences
All Capital One interview questionsSee Capital One hiring insights
Saved
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution {
    public ListNode reverseList(ListNode head) {
        // Write your code here.
    }
}
Checking account…