Insert After a Linked-List Node
Updated
Problem statement
A singly linked list is represented by values. Insert newValue immediately after the node at zero-based position, preserve every existing link, and return the resulting values.
The position always names an existing node.
Function
insertAfter(values: int[], position: int, newValue: int) → int[]Examples
Example 1
values = [4,7,9]position = 1newValue = 8return = [4,7,8,9]The new node is linked between 7 and 9.
Example 2
values = [5]position = 0newValue = 6return = [5,6]Insertion after the tail creates a new tail.
Constraints
1 <= values.length <= 100000.0 <= position < values.length.- All values fit signed 32-bit integers.
Source note: Author-written prompt excerpt retained for source fidelity.
More AMD Onsite Interview questions
- LRU CacheONSITE INTERVIEW · Seen Oct 2026
- Sort a Binary ArrayONSITE INTERVIEW · Seen Oct 2026
- Predict Runtime Method DispatchONSITE INTERVIEW · Seen Oct 2026
- K Largest Elements with QuickselectONSITE INTERVIEW · Seen Sep 2026
- Climbing StairsONSITE INTERVIEW · Seen Sep 2026
- First-Fit Arena AllocatorPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Minimum Coins for an AmountONSITE INTERVIEW · Seen Sep 2026
- Growing Circular QueueONSITE INTERVIEW · Seen Feb 2026
- Parse a Binary Firmware HeaderONSITE INTERVIEW · Seen Feb 2026
- Matrix Multiplication and Parallel PartitionsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2025
Similar questions at other companies
- Process Singly Linked List OperationsSEDEMAC · ONSITE INTERVIEW
- Head-Inserted Linked-List Hash ChainGoogle · ONSITE INTERVIEWGoogle interview questions
- LRU CacheApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
- LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
- LRU CacheServiceNow · PHONE SCREEN · ONSITE INTERVIEWServiceNow interview questions
- LFU CacheSnowflake · OA · ONSITE INTERVIEWSnowflake interview questions
- LRU Cache with TTLAutodesk · ONSITE INTERVIEWAutodesk interview questions
- Least Recently Used CacheMicrosoft · OA · PHONE SCREEN · ONSITE INTERVIEWMicrosoft interview questions
- Recover a Function-Call LRU Cache with a Write-Ahead LogAnthropic · ONSITE INTERVIEWAnthropic interview questions
- Least Recently Used CacheByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
Interview reports that mention this question
AMD interview experiences
- AMD GPU and Verification Interviews: 3 Experiences (Part 3 of 3)
- AMD SDE2 and AI Engineer Interviews: 7 Experiences (Part 2 of 3)
- AMD New Grad Role Interviews: 3 Experiences (Part 2 of 2)
- AMD ML and GPU Intern Interviews: 7 Experiences (Part 2 of 2)
- AMD Experienced SWE Interviews: 6 Experiences (Part 1 of 3)