FastPrepBuild a Sorted Circular Singly Linked List
Problems/Build a Sorted Circular Singly Linked List

Build a Sorted Circular Singly Linked List

Anduril logoAnduril● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Anduril full-time phone screen. The report asks for an ascending circular singly linked list and tests that the candidate writes. It does not list the public operations. We chose them. Our version is about 90% the same as the reported question.

Start with an empty circular singly linked list. Insert the integers from values one at a time. After each insertion, the list must stay sorted from smallest to largest. Equal values are allowed. The head always holds a smallest value, and the tail's next pointer always points back to the head. So a list with one node points to itself.

After all insertions, walk around the list exactly once, starting at the head, and return the values you visit in order. Return an empty array if no values were inserted.

Function

buildSortedCircularList(values: int[]) → int[]

Examples

Example 1

values = [4,1,3,1]return = [1,1,3,4]

Each value goes into its sorted place as it is inserted. Walking once around the list from the head, which holds the smallest value, gives the four values shown.

Example 2

values = []return = []

There are no values to insert, so no nodes are created and the answer is an empty array.

Constraints

  • 0 <= values.length <= 5000.
  • -10^9 <= values[i] <= 10^9.
  • Build and keep the linked list described above. Do not just sort the input array and return it.

More Anduril interview questions

  • Pacific Atlantic Water FlowPHONE SCREEN · Seen Aug 2026
  • Choose the Front Football TeamPHONE SCREEN · Seen May 2026
  • Maximum Visible DronesPHONE SCREEN · Seen Jun 2024
  • Sparse Vector Dot ProductPHONE SCREEN · Seen Apr 2021
  • Add Word and Suffix SearchONSITE INTERVIEW · Seen Aug 2026
  • Binary Tree Preorder TraversalONSITE INTERVIEW · Seen Aug 2026
  • Operator-First Array CalculatorONSITE INTERVIEW · Seen Aug 2026
  • Daily TemperaturesONSITE INTERVIEW · Seen Jun 2024
  • Highlighted Context WindowsONSITE INTERVIEW · Seen Jun 2024

Similar questions at other companies

  • LRU CacheAthenahealth · PHONE SCREEN
  • LRU CacheApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
  • LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • LRU CacheServiceNow · PHONE SCREEN · ONSITE INTERVIEWServiceNow interview questions
  • Alert Engine with a Repeat IntervalChronosphere · PHONE SCREEN
  • Camel CardsRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • LRU Key-Value Cache OperationsCohesity · PHONE SCREEN
  • Least Recently Used CacheMicrosoft · OA · PHONE SCREEN · ONSITE INTERVIEWMicrosoft interview questions
  • Least Recently Used CacheByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
All Anduril interview questionsSee Anduril hiring insights
Saved
class Solution {
    public int[] buildSortedCircularList(int[] values) {
        // Write your code here.
    }
}
Checking account…