https://practice.geeksforgeeks.org/problems/count-palindrome-sub-strings-of-a-string/0
this code is giving wrong ans on submisiion on gfg
plz correct it and explain as well…
https://practice.geeksforgeeks.org/problems/count-palindrome-sub-strings-of-a-string/0
this code is giving wrong ans on submisiion on gfg
plz correct it and explain as well…
reply at the earliest…
No I am not able to submit it on gfg it shows wrong ans…
Plz correct it
it shows wa on test case of string of length of 430 length…
ok now tell me how to count distinct palindromic substrings…
Step 1: Finding all palindromes using modified Manacher’s algorithm:
Considering each character as a pivot, expand on both sides to find the length of both even and odd length palindromes centered at the pivot character under consideration and store the length in the 2 arrays (odd & even).
Time complexity for this step is O(n^2)
Step 2: Inserting all the found palindromes in a HashMap:
Insert all the palindromes found from the previous step into a HashMap. Also insert all the individual characters from the string into the HashMap (to generate distinct single letter palindromic sub-strings).
Time complexity of this step is O(n^3) assuming that the hash insert search takes O(1) time. Note that there can be at most O(n^2) palindrome sub-strings of a string. In below C++ code ordered hashmap is used where the time complexity of insert and search is O(Logn). In C++, ordered hashmap is implemented using Red Black Tree.
Step 3: Printing the distinct palindromes and number of such distinct palindromes:
The last step is to print all values stored in the HashMap (only distinct elements will be hashed due to the property of HashMap). The size of the map gives the number of distinct palindromic continuous sub-strings.
plz provide the code …
i dont know manache ALGO…
i am still not able to submit this problem( [Count no of palindromic substring in a string] on geeks for geeks with the same code shared by me and submitted by u
it shows wrong ans …
@S19LPPP0202 in that case you may reopen the doubt as the code seems fine and works fine, apologies for not clearing your doubt.
Plz.now check the code again properly so that I can submit it at the earliest
plz reply and make changes in my code it shows wa on submission…fast
plz reply at the earleist