We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ff50dbc commit 910bcedCopy full SHA for 910bced
647.cpp
@@ -0,0 +1,33 @@
1
+class Solution {
2
+public:
3
+ int countSubstrings(string s) {
4
+
5
+ int n=s.length();
6
+ int count=0;
7
+ int dp[n][n];
8
+ for(int i=0;i<n;i++){
9
+ for(int j=0;j<n;j++){
10
+ dp[i][j]=0;
11
+ }
12
13
14
+ dp[i][i]=1;
15
+ count++;
16
17
+ for(int i=1;i<n;i++){
18
+ for(int j=0;j<i;j++){
19
+ if(i-1==j && s[i]==s[j]){
20
+ dp[j][i]=1;
21
22
23
+ else if(s[i]==s[j] && dp[j+1][i-1]==1){
24
25
26
27
28
29
+ return count;
30
31
32
33
+};
0 commit comments