Given an array arr[] and a number k. The task is to delete k elements which are smaller than next element (i.e., we delete arr[i] if arr[i] < arr[i+1]) or become smaller than next because next element is deleted.

**Input:**

The first line contains an integer **T, **the number of test cases. For each test case, the first line contains an integer **n, **denoting the size of the array. Next line contains n space separated integers, followed by an integer **k**, denoting the number of elements to be deleted from the array.

**Output:**

For each test case, the output is the array arr[] after deleting the k elements from the array if possible, else print the left array as it is.

**Constraints:**

1<=T<=100

2<=n<=100

1<=k<=100

**Example:**

**Input**

4

3

3 100 1

1

5

20 10 25 30 40

2

5

23 45 11 77 18

3

2

2 5

2

**Output**

100 1

25 30 40

77 18

5

**Explanation:
1.** arr[0] < arr[1] means 3 is less than 100, so delete 3.

Author: Vanshika_pec

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

_Shubham_Jain_06 | 404 |

maggiiiii | 315 |

Savage_19 | 310 |

ritikdagar0203 | 241 |

thanuvinu94 | 233 |

Bishnu Dev Panda | 810 |

_Shubham_Jain_06 | 715 |

okayboss | 652 |

maggiiiii | 598 |

Savage_19 | 576 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4925 |

Quandray | 4547 |

Login to report an issue on this page.