title: Find the maximum product of two non overlapping palindromic subsequences
body: <p>I am trying to find the maximum product of two non overlapping palindromic sub-sequences of string <code>s</code> that we'll refer to as <code>a</code> and <code>b</code>. I came up with below code but it's not giving correct output:</p>
  
  <pre><code>public static int max(String s) {
      int[][] dp = new int[s.length()][s.length()];
  
      for (int i = s.length() - 1; i &gt;= 0; i--) {
          dp[i][i] = 1;
          for (int j = i+1; j &lt; s.length(); j++) {
              if (s.charAt(i) == s.charAt(j)) {
                  dp[i][j] = dp[i+1][j-1] + 2;
              } else {
                  dp[i][j] = Math.max(dp[i+1][j], dp[i][j-1]);
              }
          }
      }
      return dp[0][s.length()-1];
  }
  </code></pre>
  
  <p>For input string "acdapmpomp", we can choose <code>a</code> = "aca" and <code>b</code> ="pmpmp" to get a maximal product of score 3 * 5 = 15. But my program gives output as 5.</p>