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.
The first line will contain an integer T (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.
Print the sorted Array List after removing all the elements which are less than integer k.
1 < = T < = 1000
1<= n , k , element<= 104
1 6 9 2 11
1 4 6 9
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.