We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c14ea01 commit 64758f0Copy full SHA for 64758f0
kth-smallest-element-in-a-bst/kayden.py
@@ -27,4 +27,4 @@ def dfs(node):
27
28
dfs(root)
29
30
- return self.result
+ return self.result
palindromic-substrings/kayden.py
@@ -0,0 +1,20 @@
1
+class Solution:
2
+ def countSubstrings(self, s: str) -> int:
3
+ n = len(s)
4
+ count = n
5
+ isPalindrome = [[False for _ in range(n)] for _ in range(n)]
6
+
7
+ for i in range(n):
8
+ isPalindrome[i][i] = True
9
+ if i < n-1 and s[i] == s[i+1]:
10
+ isPalindrome[i][i+1] = True
11
+ count += 1
12
13
+ for length in range(3, n + 1):
14
+ for i in range(n - length + 1):
15
+ j = i + length - 1
16
+ if isPalindrome[i+1][j-1] and s[i] == s[j]:
17
+ isPalindrome[i][j] = True
18
19
20
+ return count
0 commit comments