diff --git a/5.LongestPalindromicSubstring.cpp b/5.LongestPalindromicSubstring.cpp new file mode 100644 index 0000000..7abbc8d --- /dev/null +++ b/5.LongestPalindromicSubstring.cpp @@ -0,0 +1,29 @@ +class Solution { +public: + string longestPalindrome(string s) { + string ans=""; + int st=0,end=0,len=0; + for(int i=0;i=0 && hlen){ + len=h-l+1; + st=l,end=h; + } + l--,h++; + } + l=i,h=i+1; + while(l>=0 && hlen){ + len=h-l+1; + st=l,end=h; + } + h++,l--; + } + } + for(int i=st;i<=end;i++){ + ans+=s[i]; + } + return ans; + } +}; \ No newline at end of file diff --git a/README.md b/README.md index cfa0260..c3f3416 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,7 @@ Once done kindly update the README.md file by updating the Problems : by adding
  • 1832. Check if the Sentence Is Pangram. [Easy]
  • 2007. Find Original Array From Doubled Array. [Medium]
  • 2095. Delete the Middle Node of a Linked List. [Medium]
  • +
  • 5. Longest Palindromic Substring [Medium].