Delete List

0

0 votes
Easy
Problem

A list of N nodes is given. Each node is having some value. There K nodes to be deleted. A node is to be deleted according to the following algorithm:

flag=false
for i = 1 to list_length-1{
     if (list[i].val< list[i+1].val)
        delete i th node
       flag=true
       break
if(flag == false)
     delete the last node

Input Format:
First line contains T number of test cases. First line of each test case contains N, the number of nodes and K ,the number of nodes to be deleted. Followed by n space separated integers.
Output Format:
Print the contents of list after deletion.
Constraints
All the numbers are well with in the integer range.

Sample Input
2
3 1
3 100 1
5 2
19 12 3 4 17
Sample Output
100 1 
19 12 17
Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?