Storing sub in map
if ( ! sorted_subsequence . containsKey ( sub . length ( ) ) ) sorted_subsequence . put ( sub . length ( ) , new HashSet < > ( ) ) ; sorted_subsequence . get ( sub . length ( ) ) . add ( sub ) ; } for ( Map . Entry < Integer , HashSet < String > > it : sorted_subsequence . entrySet ( ) ) {