Hi, everyone.
So today we are going to solve this problem, valid palindrome.
OK, so given a string, we have to check whether the string is a palindrome or not.
For example, this string A.B.C., so this is not a palindrome.
So what is the meaning of palindrome?
So palindrome means, if you will, read from left to right or if you read from right to left, then
they both will be equal.
OK, so in this case, if I will read from left to right, this is ABC and if I will read from right
to left, then this is S.B.
And obviously these two are not equal.
OK, so our output should be false.
OK, so the return type of our function will be a boolean value and the input will be a string.
Let's take one more example, so if I have this string A, B, if you will read from left to right,
then obviously this is B and if you will read from right to left, then also it is A B and these both
are equal.
So I will return.
True.
OK, so this is the significance.
This is the meaning of a palindrome.
OK, so how to check with a given string is a palindrome of note.
So this is very simple.
For example, let's say this is let's take a string.
So A, B, C, C and let's say the.
OK, so this is basically a palindrome.
Now let's see how we will check it.
So take two point us start pointer and pointer, OK, start and end vertical.
So and they both are equal.
Move ahead.
So this is a start.
This is.
And so basically what I am doing here, I am doing a start plus and I'm going and minus minus.
OK, now compare me with B so be NBA to move ahead.
So we'll start plus plus and minus minus.
Now see an equal move ahead.
So we'll start plus plus and minus minus.
So compare the with B so these equal to the then move ahead.
So I will start plus plus and minus minus two start will come here and will come here.
So this will become start basically and and will come here.
So when we will stop.
So when the start is less than end or basically when the end.
OK.
So basically when the start becomes good then.
And so this is the condition.
OK, so when the start becomes good then end, then I can say that my string is basically a palindrome.
OK, so I'm just quickly writing the code and then we will see the little problem.
OK, so the problem is a little bit of advanced version of this problem.
OK, so for simply checking a palindrome, how we can write the code.
So I will take two pointer.
So the first pointer will be at the start and the end point will be and minus one basically at the end
point.
And then what is the conditions of condition is very simple.
We'll start this less than than to end what I have to do, I have to compare both start and end.
So let's say many of the error is a.
So if a start is not close to AOF and then you can simply return false, you can simply return false.
Otherwise what you can do, we will lose start plus.
Plus we will do and minus minus.
And finally we will return to.
OK, so this is when the palindrome vendor given string is very simple string.
OK, so the lead problem, the literal problem is very different.
It is not very different.
It is slightly different.
OK, so this is our little problem.
So as you can see, so this problem is a little bit different, although the concept will remain the
same.
So how we will check.
So for example, I will compare capitally and small.
So in this case they are assuming both are.
OK, so capital and small.
They both are slim.
Then if I will do so, this is my start, then this is my end.
So if I will do start placeless, I will reach here.
Basically this is a space.
OK, so this problem says if it is a space, then move ahead.
So I will reach M.
And similarly, I am here, so mnm motoric, well, I will move ahead.
So basically this problem is you will be given space's, you will be given Goma's, you will be given
capital and small letters and you will be given semicolon.
You will be given special characters and so on.
So basically you will be given a complex string.
But what you will compare, you will only compare numbers.
And you will compare Alphabet's and you will skip all these.
OK, so we will skip spaces, we will speak, we will skip special characters, for example, Daulaire
or for example and or and so on.
OK, so we have to compare only numbers and alphabets.
OK, and in the alphabet, both upper and lower case, they are equal.
OK, so they are not different, but apparently what cases they are saying, OK, so the approach is
exactly the same.
Take two pointers at the first start point and then the pointer moves start and end and compare.
OK, so if you start and end, if they are not equal, you can return false and if they are equal,
you can to true and you have to take care of these type of cases.
OK, we will only consider no alphabet's.
OK, so let us read the code, so the approach is very simple, we have to take two variables.
Start will be zero.
And the end will be basically Astarte size minus one.
Let's store it basically and is basically the same as Nazis'.
Now, what will be the end so and will be N minus one.
OK, now what we have to do.
So we'll start this list on articles two and.
We will do something, and at the end we will return to.
OK, so inside this part, what we have to do.
So first of all.
What we have to do, we have to check whether they start and end, they are equal or not.
So if.
So, OK, so this is let's change the name.
This is a basically OK, so this is a.
So if the start is not close to end.
I can return.
False else, I will do start placeless and I will do and minus minus.
OK, but this code is not enough, but I have to do so.
The characters can be uppercase or lowercase, so there is a function to appear.
OK, so I will use a function to appear to WOPR function.
So to.
A paratrooper function takes.
A character has input and it will return the Oscar value.
OK, so to upper.
It will return the value of the character.
OK, so I am using to function now, is this correct?
So I think this is still not correct.
So basically, I have not handled the cases when the character is basically space or basically special
characters.
So I have to skip all this.
OK, so I have to skip all of them.
So I'll start this less than what it to end what I have to do, I have to skip all those characters.
And the character is neither Alphabeat and nor No.
So I will give a start what I have to do, I will start placeless.
And similarly, the same condition for the end.
So while the end character is neither Alphabeat and not a numeric number, I will do it and minus minus.
OK, so let me show you.
So basically this function is called.
So what dysfunctional dysfunction will take a character as input and it will return true if the character
is either Alphabeat or if the character is either a no and in all other cases dysfunctional, it unfolds.
OK, so basically if it returns false, that means I have like Space's commas, semicolons, Dolev symbol.
Aanenson And our aim was to skip all these characters.
OK, so if they start, if they start as all these characters, then I will do start placeless.
And similarly if the end and also all these characters then I will do and minus minus now at this point.
At this point, I am very sure that I have alphabet or numbers.
OK, I have alphabet on numbers.
I am very sure at this point then what I am doing, I am using to upper function.
So do upper functions or to upper function.
What it will do, it will take a character input and it will return the ascribe value.
OK, and then we are comparing the ASCII values.
OK, very simple.
If the values are different, I am returning false.
Otherwise I will lose plus plus and minus minus.
And finally I am returning.
True.
So basically the time complexities win and the space complexities or even.
OK, so this is time and this is space.
We are not using any extra space.
OK, so constant space and linear time.
OK, so there are many functions, for example, to operate, there are many functions like to lower.
We have also functions like his lower.
Like is upper.
And so on.
OK.
And like we also have functions like is Richard is Alpha, OK?
We have functions like is digit is alpha.
And and many more.
OK, so we have many functions that are already implemented in C++ for our own help.
OK, so here I'm using is Ellum OK?
Is a lung function that will return MITRO if the given character is either Alphabeat or no, otherwise
it will return false.
OK, so we need this function here because you can see the example.
I do not need to compare spaces.
OK, I have to skip spaces, I have to skip commas.
I have to skip this columns and so on.
OK, so for skipping we are using is Ellem and obviously you can see so this is uppercase and this is
lowercase.
So for upper and lower I'm using two upper function, I'm converting the I'm converting everything to
uppercase.
OK.
OK, so I think everything is fine now.
Let us try to land our good.
OK, now let's Sombat.
So our goal will work fine.
OK.
I think we did everything correctly, so the time, complexities in the space, complexities on OK,
so if you have any doubt in this problem, so this is valid Burrendong problem.
So if you have any doubt in this problem, you can ask me.
OK, thank you.