Dreamplay and Upside Down
Practice
4 (22 votes)
Algorithms
Dynamic programming
Easy
String manipulation
Two dimensional
Problem
95% Success 8853 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Dreamplay likes the strings that read the same upside down, that is, if we reverse the entire string, the string remains unchanged. in other words, palindrome strings
Bob does not want to upset his friend, and would thus like to make some changes, to the string P he already has, so that the string P is liked by dreamplay. Bob is allowed to make only two kinds of changes.

  1. Add a character at end.
  2. Replace a character.

Moreover, since Dreamplay is waiting for the string, Bob wants to do this in minimum steps.
Can you find minimum number of steps needed to change the string P such that it reads same from both ends.

Input
Only line of input consists of the string P

Output
Print a single integer, the minimum number of steps needed.

Constraints

  • String P consists only of lowercase latin letters.
  • \( 1 \leq length(P) \leq 5000 \)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
63 votes
Tags:
Dynamic ProgrammingEasyOpenTwo dimensional
Points:30
8 votes
Tags:
AlgorithmsApprovedDynamic ProgrammingEasyGrammar-VerifiedRecruitTwo dimensional
Points:30
13 votes
Tags:
Dynamic ProgrammingEasyTwo dimensional