Problem of the Day : Form a palindrome

  Рет қаралды 194

Learn Together

Learn Together

Күн бұрын

Given a string, find the minimum number of characters to be inserted to convert it to palindrome.
For Example:
ab: Number of insertions required is 1. bab or aba
aa: Number of insertions required is 0. aa
abcd: Number of insertions required is 3. dcbabcd
Example 1:
Input:
abcd
Output:
3
Explanation:
Here we can append 3 characters in the
beginning,and the resultant string will
be a palindrome ("dcbabcd").
Example 2:
Input:
aba
Output:
0
Explanation:
Given string is already a pallindrome hence
no insertions are required.
Your Task:
You don't need to read input or print anything. Your task is to complete the function findMinInsertions() which takes string S as input parameters and returns minimimum numser of insertions required.
Expected Time Complexity: O(|S|2)
Expected Auxiliary Space: O(|S|2)

Пікірлер: 2
@learntogether7741
@learntogether7741 2 жыл бұрын
A video edit is currently under process, apologising for some wrong content from 4.07 to 7.17
@learntogether7741
@learntogether7741 2 жыл бұрын
Foa abda, let our s1 = abda reverse s1 = adba here when we look we can see our longest common subsequence is ada which is of length 3 So the minimum insertion will be 4 - 3 = 1. We can either change d to b to make the string abba or change b to d to make adda. @shubham tripathy. Thank you
Problem of the Day : Smallest greater elements in whole array
22:54
Problem of the Day : LCP (Longest Common Prefix)
15:57
Learn Together
Рет қаралды 184
Каха и лужа  #непосредственнокаха
00:15
Disrespect or Respect 💔❤️
00:27
Thiago Productions
Рет қаралды 43 МЛН
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
Programming Is Cooked
9:30
ThePrimeTime
Рет қаралды 126 М.
Problem of the Day : Next element with greater frequency
17:40
Learn Together
Рет қаралды 214
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Beginners Should Think Differently When Writing Golang
11:35
Anthony GG
Рет қаралды 123 М.
"Clean" Code, Horrible Performance
22:41
Molly Rocket
Рет қаралды 910 М.
GFG | Problem of the Day : Min Coin - Knapsack
23:38
Learn Together
Рет қаралды 111
How to STUDY so FAST it feels like CHEATING
8:03
The Angry Explainer
Рет қаралды 1,8 МЛН
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 183 М.