1
00:00:00,840 --> 00:00:01,830
Hi everyone.

2
00:00:01,830 --> 00:00:05,880
Let's now code the second method that we discussed.

3
00:00:05,880 --> 00:00:09,300
So over here I have the code that we have written as per the first method.

4
00:00:09,300 --> 00:00:11,670
Now there's just a minor change to this right?

5
00:00:11,670 --> 00:00:16,230
Instead of making new string to compare, we have to make this an array.

6
00:00:16,230 --> 00:00:16,470
Right.

7
00:00:16,470 --> 00:00:17,850
So this has to be an array.

8
00:00:17,850 --> 00:00:21,030
So uh, this is an empty array at this point.

9
00:00:21,030 --> 00:00:25,020
Now instead of appending over here we will use dot push right.

10
00:00:25,020 --> 00:00:31,530
So we'll push the characters from the existing string from the back to the front to the array.

11
00:00:31,920 --> 00:00:35,640
So at this point new string to compare this is an array.

12
00:00:35,640 --> 00:00:42,120
And then before we do this comparison we have to join the elements of the array.

13
00:00:42,120 --> 00:00:45,120
So new string to compare at this point is just an array right.

14
00:00:45,120 --> 00:00:46,470
So I'm not changing the name.

15
00:00:46,470 --> 00:00:47,640
This is actually not a string.

16
00:00:47,640 --> 00:00:48,960
This is an array at this point.

17
00:00:48,960 --> 00:00:52,410
So we need to join this to make it a string.

18
00:00:52,410 --> 00:00:55,320
So we use the dot join function for this.

19
00:00:55,320 --> 00:00:59,670
Now at this point this part over here will be a string.

20
00:00:59,670 --> 00:01:02,340
And then we check whether this is equal to the given string.

21
00:01:02,340 --> 00:01:04,080
So if it's equal we return true.

22
00:01:04,080 --> 00:01:06,090
And if it's not we return false.

23
00:01:06,090 --> 00:01:08,040
Now let's test our solution.

24
00:01:08,040 --> 00:01:10,440
So let's call the function is palindrome.

25
00:01:10,440 --> 00:01:10,770
Check.

26
00:01:10,770 --> 00:01:14,100
And let me pass the string ABC to this.

27
00:01:14,100 --> 00:01:17,370
And let's run this and see what we get at this point.

28
00:01:17,370 --> 00:01:21,270
So I'm running it and I get false because ABC is not a palindrome.

29
00:01:21,270 --> 00:01:25,710
What if it was ABC BA at this case I get true right.

30
00:01:25,710 --> 00:01:28,950
Again if I have a A this is true.

31
00:01:29,550 --> 00:01:33,960
If I have a and capital A, this should give us false.

32
00:01:33,960 --> 00:01:36,150
So yes our solution is working.
