1
00:00:00,170 --> 00:00:04,280
The space and time complexity of this approach is pretty straightforward.

2
00:00:04,310 --> 00:00:07,580
You can see that we are using a 2D DP array over here.

3
00:00:07,580 --> 00:00:13,940
So that's why the space complexity is of the order of n squared, where n is the length of the string

4
00:00:13,940 --> 00:00:19,010
which is given to us, and the time complexity is of the order of n squared.

5
00:00:19,010 --> 00:00:25,190
Again, the reason for this is the number of substrings that can be formed from a string of length n,

6
00:00:25,190 --> 00:00:29,450
so the number of substrings that can be formed is of the order of n square.

7
00:00:29,450 --> 00:00:33,110
And for each substring we are doing constant time operations.

8
00:00:33,110 --> 00:00:38,390
Now, we have discussed this in great detail when we discussed the time complexity for the tabulation

9
00:00:38,390 --> 00:00:43,790
approach for the palindromic substrings question, and the same reason applies over here as well.

10
00:00:43,790 --> 00:00:47,210
So the time complexity is of the order of n square.
