Sort an Absolute-Value-Sorted Linked List
Updated
Problem statement
A singly linked list is sorted by nondecreasing absolute value. Rearrange its existing nodes so their integer values are in ordinary nondecreasing order and return the new head.
Function
sortAbsoluteList(head: ListNode) → ListNodeExamples
Example 1
head = [1,-2,-3,4,-5]return = [-5,-3,-2,1,4]Moved or new
Negative nodes reverse magnitude order before the positive nodes.
Example 2
head = [-1,-2,-3]return = [-3,-2,-1]Moved or new
All negative nodes reverse.
Constraints
- The list has at most
10^5nodes. - Absolute values are nondecreasing along the input list.
More Bloomberg LP Onsite Interview questions
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Top K Frequent WordsONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Decode StringPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Minimum Replacements to Make Two Strings AnagramsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Currency Conversion RatePHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Sort a Linked List in Descending OrderMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Minimize Task Resource ConsumptionNVIDIA · OANVIDIA interview questions
- Merge Timestamped Record ListsNuro · PHONE SCREENNuro interview questions
- Filter Linked-List Nodes and Keep Top KGoogle · PHONE SCREENGoogle interview questions
- Chain MergeRubrik · OARubrik interview questions
- Build a Sorted Circular Singly Linked ListAnduril · PHONE SCREENAnduril interview questions
- Sort a Linked ListAdobe · PHONE SCREENAdobe interview questions
- Merge K Sorted Linked ListsBharatPe · PHONE SCREEN
- LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)