Dsa
Linked List
Warm-up
Insert Node into Sorted Linked List
You have a sorted linked list and an integer value. Your task is to insert the integer into the correct position in the linked list to keep it sorted.
Input format:
- The first line contains an integer n (0 <= n <= 100), the number of nodes.
- The second line contains n space-separated integers representing the sorted linked list.
- The third line contains an integer value to insert.
Output format:
- A single line with the values of the updated sorted linked list, separated by spaces.
Example:
Input:
3
1 3 5
4
Output:
1 3 4 5
Key concepts
linked_listinsertionsorting
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now