Sort by

recency

|

46 Discussions

|

  • + 0 comments

    Memoization, pased all test cases.

    public static int maxPal(string s,int l,int r,int[][] memo){ if(l==r) return 1; if(l>r) return 0;

            if(memo[l][r]!=-1) return memo[l][r];
            if(s[l]==s[r]) {
                    memo[l][r]=2+maxPal(s,l+1,r-1,memo);
                    return  memo[l][r];
            }
            int left=maxPal(s,l+1,r,memo);
            int right=maxPal(s,l,r-1,memo);
            memo[l][r]=Math.Max(left,right); 
            return   memo[l][r];
    } 
    
    static int playWithWords(string s) {
            /*
             * Write your code here.
             */
            int max=0;
            int[][] memo1=new int[s.Length][];
            int[][] memo2=new int[s.Length][];
             for(int j=0;j<s.Length;j++) {
                     memo2[j]=new int[s.Length];
                     memo1[j]=new int[s.Length];
             }
            for(int i1=0;i1<s.Length;i1++){
                    for(int i2=0;i2<s.Length;i2++){
                                    memo2[i1][i2]=-1;
                                     memo1[i1][i2]=-1;
                    }
            }
            for(int i=1;i<s.Length;i++){
    
                    int left=maxPal(s,0,i-1,memo1);
                    int right=maxPal(s,i,s.Length-1,memo2);
                    max=Math.Max(max,left*right);
            }
            return max;
    }
    
  • + 0 comments

    Does arthrogenix works

  • + 0 comments

    Easily access your MEPCO online bill by entering your 14-digit reference number. Instantly view your bill details, payment history, and due dates for convenient and seamless bill management.

  • + 0 comments

    Easily access your MEPCO online bill by entering your 14-digit reference number. Instantly view your bill details, payment history, and due dates for convenient and seamless bill management.

  • + 1 comment

    how can we create an for pilates that is taking place in ankara turkey as Cayyolu Reformer Pilates