Question: Problem 5 : removeNodes ( lst , i , n ) Starting from the ith node in a ( possibly empty ) linked list, remove

Problem 5: removeNodes(lst, i, n)
Starting from the ith node in a (possibly empty) linked list, remove the next n nodes, not including the
ith node.
We say the head of the input list is the first node, i.e., i =1.
When i =0, your function should start by removing the head.
Note:
n >=0
i >=0
i + n <= lst.length()
Example: let lst be a linked list 1->2->3->4->5->6
1. When i =2 and n =3, return the linked list 1->2->6.
Explanation: The second node (i =2) is 2. Removing the next three nodes (n =3) means removing
nodes 3,4, and 5. The remaining ones are 1,2,6.
2. When i =0 and n =3, return the linked list 4->5->6.
Explanation: Since i =0, we remove the first three nodes (n =3) from the beginning of lst , which
are 1,2,3. The remaining ones are 4,5,6.
2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!