Java Collections | Set 8 (TreeSet)
Basic Accuracy: 43.55% Submissions: 280 Points: 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]

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.