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 48e6101 commit 5165eb4Copy full SHA for 5165eb4
palindromic-substrings/wogha95.js
@@ -0,0 +1,32 @@
1
+// TC: O(n^3)
2
+// SC: O(1)
3
+
4
+/**
5
+ * @param {string} s
6
+ * @return {number}
7
+ */
8
+var countSubstrings = function(s) {
9
+ let count = 0;
10
11
+ for (let left = 0; left < s.length; left++) {
12
+ for (let right = left; right < s.length; right++) {
13
+ if(checkIsPalinDrome(left, right)) {
14
+ count += 1;
15
+ }
16
17
18
19
+ return count;
20
21
+ function checkIsPalinDrome(left, right) {
22
+ while (left < right) {
23
+ if (s[left] !== s[right]) {
24
+ return false;
25
26
+ left += 1;
27
+ right -= 1;
28
29
30
+ return true;
31
32
+};
0 commit comments