Java Iterator
Submissions: 1988   Accuracy:

26.68%

  Difficulty: Basic   Marks: 1

It is a universal iterator as we can apply it to any Collection object. By using Iterator, we can perform both read and remove operations.Try this problem using Iterator.

Given n spaced integers which are to be put in an ArrayList and an integer k.Iterate the Array List using iterator and remove all the numbers of the ArrayList which are less than k . And then print the sorted ArrayList.

Input: 
The first line will contain an integer (number of test cases). First line of each test case consists of two integers n and k. Second and last line of each test case consists of n spaced integers.

Output: 
Print the sorted Array List after removing all the elements which are less than integer k.

Constraints: 
1 < = T < = 1000
1<= n , k , element<= 104

Example:
Input:

2
5 8
1 6 9 2 11
4 13
1 4 6 9

Output:
[9, 11]
[]

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: S_A
Author: saksham0751


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.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.