JAVA | SIMPLE EXPLANATION | CODE WITH DETAILED COMMENTS
Simple Explanation of Bottom-up (Tabulation) approach\n\nhttps://www.youtube.com/watch?v=7UpPnWW9GJY\n\nFor more:-\nTelegram group - https://t.me/+IK5-RpKtVWUxM
Simple Explanation of Bottom-up (Tabulation) approach\n\nhttps://www.youtube.com/watch?v=7UpPnWW9GJY\n\nFor more:-\n**Telegram group** - https://t.me/+IK5-RpKtVWUxMDI1\n**Telegram channel**- https://t.me/betterSoftEng\n\n```\nclass LongestPalindromeInAStringSolution{\n    static String longestPalin(String S){\n        // code here\n        if(S.length() == 0) return S;\n        if(S.length() == 1) return S;\n\n        //Initializing longest Palindromic substring found so far with\n        //first letter\n        int maxLength = 1;\n        int maxPalinStartIndex = 0;\n        int maxPalinEndIndex = 0;\n\n        int i = 1;\n        int n = S.length();\n\n        int j; int k;\n\n        int currentLength;\n        int currentPalinStartIndex;\n        int currentPalinEndIndex;\n\n        //No use of having last letter as centre. Because, max palindromic\n        //substring from there can be of just length = 1.\n\n        //One iteration of this loop fixes a centre.\n        for(i=0; i<n-1; i++) {\n            //Centre length = 1\n            //These two are pointers that will move - one to the left\n            // one to the right.\n            j=i-1;\n            k=i+1;\n\n            //Below information will keep track of current palindrome we have\n            currentLength = 1;\n            currentPalinStartIndex = i;\n            currentPalinEndIndex = i;\n\n            //While no index breaches boundary and we have equal characters\n            while(j>=0 && k<n && S.charAt(j) == S.charAt(k)) {\n                currentPalinStartIndex = j;\n                currentPalinEndIndex = k;\n                currentLength = currentLength + 2;\n                j--;\n                k++;\n            }\n\n            if(currentLength > maxLength) {\n                maxLength = currentLength;\n                maxPalinStartIndex = currentPalinStartIndex;\n                maxPalinEndIndex = currentPalinEndIndex;\n            }\n\n            // If Centre length = 2 is possible\n            if(S.charAt(i) == S.charAt(i+1)) {\n                currentLength = 2;\n                currentPalinStartIndex = i;\n                currentPalinEndIndex = i+1;\n\n                j=i-1;\n                k=i+2;\n\n                while(j>=0 && k<n && S.charAt(j) == S.charAt(k)) {\n                    currentPalinStartIndex = j;\n                    currentPalinEndIndex = k;\n                    currentLength = currentLength + 2;\n                    j--;\n                    k++;\n                }\n\n                if(currentLength > maxLength) {\n                    maxLength = currentLength;\n                    maxPalinStartIndex = currentPalinStartIndex;\n                    maxPalinEndIndex = currentPalinEndIndex;\n                }\n            }\n\n        }\n\n        return S.substring(maxPalinStartIndex, maxPalinEndIndex+1);\n\n    }\n}\n```
['Dynamic Programming', 'Java']