I have some arraylist string with keyword inside like that !
A windows is arraylist string with keyword is bold
Struct of window : 9 words before + keyword + 9 words after
You can see some window overlaping

How to i combine that arraylist to receive like that :

Thanks
If you’re not too worried about performance, a simple
subList/equalsmatching is very easy to write:This prints:
The algorithm works as it says: to build
List<String> joined, given aList<String> textAsList, we find the longestsubListmatching between the “tail” ofjoinedand the “head” oftextAsList.