Java Collections | Set 8 (TreeSet)
Submissions: 222   Accuracy:

37.82%

  Difficulty: Basic   Marks: 1

Given n strings added in a TreeSet and four characters a,b,c,d. Firstly print all the strings which are less than a , then print all the strings which are greater than or equal to b. In the end print all the strings which are greater than or equal to c and less than d i.e between c and d ( excluding d ). 

Input:

The first line of input is T denoting the number of testcases. First line consists of an integer n. Next line contains n spaced strings. Last line of each test case consists of 4 space separated characters.

Output:

For each test case output will be in three lines:
First Line :  Print all the strings which are less than a (char variable).
Second Line : Print all the strings which are greater than or equal to b (char variable).
Third Line :  Print all the strings which are greater than or equal to c and less than d i.e between c and d ( excluding d ). 

Constraints:

1<=T<=100
1<=N<=100
1<=Length of string<=100

Example:

Input:

1
3
sa ka da
s k c s

Output:

[da, ka]
[ka, sa]
[da, ka]

** 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.