public static int findLCS(String S, String T){
        int m = S.length();
        int n = T.length();
        int[][] memo = new int[m + 1][n + 1];
        Set<String> result = new HashSet<String>();

        int longest = 0;
        for(int i = 0; i < m + 1; i ++){
            for(int j = 0; j < n + 1; j++){
                if(i == 0 || j == 0){
                    memo[i][j] = 0;
                }else if(S.charAt(i - 1) == T.charAt(j - 1)){
                    memo[i][j] = memo[i - 1][j - 1] + 1;
                    if(memo[i][j] > longest){
                        longest = memo[i][j];
                        result.clear();
                    }
                    if(memo[i][j] == longest){
                        result.add(S.substring(i - longest, i));
                    }
                }else{
                    memo[i][j] = 0;
                }
            }
        }
        System.out.println(result);
        return longest;
    }