Simple variation of LCS


#1

Comment body goes herepublic class Solution {
public int anytwo(String A) {
int n = A.length();
int[][] dp = new int[n+1][n+1];

   String B = new String(A);
   
   for(int i=1;  i<=n; i++){
       for(int j=1; j<=n; j++){
           if(A.charAt(i-1) == B.charAt(j-1) && i != j){
               dp[i][j] = 1+dp[i-1][j-1];
           }else{
               dp[i][j] = Math.max(dp[i-1][j],dp[i][j-1]);
           }
       }
   }

if(dp[n][n] >1){return 1;}else{return 0;}
}
}
.