Company: HCL TECH

Difficulty: medium

Problem Statement

Linked List Creation Given a sequence of `n` node values in linked-list order, repeatedly select the nodes at odd positions (positions 1, 3, 5, ...) from the current list. Append the selected nodes to a new list in their current order and remove them from the current list. Continue until the current list is empty. Print the new list. Input Format The first line contains `n`. The second line contains `n` integer node values. Output Format Print the values of the resulting list in order, separated by spaces. Constraints `1 ≤ n ≤ 100000`; each value fits in a signed 64-bit integer. Notes Positions are 1-based and are recalculated after every round.

More HCL TECH OA questionsInterview experiences