DAYS
HOUR
MINS
SEC
Error
Given string str of length N. The task is to find the minimum characters to be added at front to make string palindrome.
Note: A palindrome is a word which reads the same backward as forward. Example : madam.
Example 1:
Input:
S = "abc"
Output: 2
Explanation:
Add 'b' and 'c' at front of above string to make it
palindrome : "cbabc"
Example 2:
Input:
S = "aacecaaaa"
Output: 2
Your Task:
You don't need to read input or print anything. Your task is to complete the function minChar() which takes a string S and returns an integer as output.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
Constraints:
1 <= S.length <= 105
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes