We construct a matrix to keep track of maximal length suffix of all substrings. We can find the maximal value from this matrix and traverse from that cell diognally upwards till the cell value becomes ...
System.out.println(s1.substring(2)); //from 2nd index to last System.out.println(s1.substring(0, 1)); System.out.println(s1.substring(2,4)); //from 2nd index to 4th index ...