FastPrepSort a Linked List
Problems/Sort a Linked List

Sort a Linked List

Adobe logoAdobe● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: You sort a singly linked list into increasing order. An Adobe report from a candidate for a product intern role in the SheCodes on-campus drive (August 2023) lists it as the first of two coding questions. It came in the online interview that followed an online test. Before the coding, the interviewer asked about a favourite subject from the resume and about networking and operating systems. The report asks for a slow first answer and then a faster one. It shows one short example in increasing order. It gives no limits.

We chose these rules. Repeated values are kept. Lists have 1 to 2000 nodes, with values from -10^5 to 10^5. We wrote new examples. The tests check only the sorted list, so a slow answer also passes. The editorial covers both a simple answer and merge sort.

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

You are given the head of a singly linked list. Sort the list so that its values are in increasing order, and return the head of the sorted list.

Values may repeat; every node stays in the list, so equal values appear next to each other in the result.

Function

sortLinkedList(head: ListNode) → ListNode

Examples

Example 1

head = [7,-3,12,0,5]return = [-3,0,5,7,12]
head
7-31205
→
return
-305712
Moved or new

The values in increasing order are -3, 0, 5, 7, 12, so the sorted list is [-3,0,5,7,12].

Example 2

head = [9,9,2,9]return = [2,9,9,9]
head
9929
→
return
2999
Moved or new

Equal values all stay in the list: [2,9,9,9].

Example 3

head = [1]return = [1]
head
1
→
return
1

A single node is already sorted.

Constraints

  • The list has between 1 and 2000 nodes.
  • -10^5 <= node.val <= 10^5

More Adobe Phone Screen questions

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
  • Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
  • Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
  • Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
  • Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
  • Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
  • Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026

Similar questions at other companies

  • Merge K Sorted Linked ListsBharatPe · PHONE SCREEN
  • Sort a Linked List in Descending OrderMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Locate Vehicles with Square QueriesApplied Intuition · PHONE SCREENApplied Intuition interview questions
  • Merge Timestamped Record ListsNuro · PHONE SCREENNuro interview questions
  • Nested Set Structural EquivalencePinterest · PHONE SCREEN · ONSITE INTERVIEWPinterest interview questions
  • Flatten a Multilevel Doubly Linked ListBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Filter Linked-List Nodes and Keep Top KGoogle · PHONE SCREENGoogle interview questions
  • Swap Adjacent Linked List NodesNutanix · PHONE SCREENNutanix interview questions
  • Build a Sorted Circular Singly Linked ListAnduril · PHONE SCREENAnduril interview questions
  • Reverse a Linked ListCisco · PHONE SCREENCisco interview questions

Interview reports that mention this question

  • Adobe Product Intern Interviews: 15 Experiences (Part 3 of 4)

Adobe interview experiences

  • Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
  • Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
  • Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
  • Adobe New Grad MTS Interview Questions: 7 Experiences
  • Adobe ML/Research Intern Interviews: 12 Experiences (Part 4 of 4)
All Adobe interview questionsSee Adobe 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 sortLinkedList(ListNode head) {
        // Write your code here.
    }
}
Checking account…