Print the nodes of linked list at given indexes

Given a collection of sorted index, Our goal is to find and print all nodes on linked list which is exist on given index. For example.

 Example 1
 Input List : 4 → 8 → 7 → 3 → 8 → 6 → 10 → 19 → -5 → NULL
 Index List : 2 → 4 → 7 → NULL
 Output     : 8   3   10 [value at index]

 Example 2
 Input List : 4 → 8 → 7 → 3 → 8 → 6 → 10 → 19 → -5 → NULL
 Index List : 3 → 5 → 6 → 8 → NULL
 Output     : 7  8  6  19

This problem are based on traversal of linked list.




Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment







© 2022, kalkicode.com, All rights reserved