Computer Science, asked by anu24624, 7 months ago

Q2. You are given a sequence of integers terminated with a -1. The -1 is not part of the input sequence. Next, you are given a positive number N.

You have to create a linked list with the input sequence of integers as entries. You can use the following structure.

struct node{

};

int data; struct node *next;

Now, you have to delete all except the last N elements from the linked list, and print the resulting list. (i.e. The resulting list will consist of only the last N elements from the list.)

If N is longer than the length of the linked list, you must print -1.

While printing, the entries of the list must be separated by a single space.

Sample Test Cases

Test Case 1

Test Case 2

Test Case 3

Input

123-1

3

1234-1

2

1234-1

1 1

Output

123

34

4​

Answers

Answered by pikachu8650
0

Answer:

jskjshdhsgdhdggdusysususihxbxbxhwuwjdjrududhx

Similar questions