File tree 1 file changed +4
-3
lines changed
scripts/algorithms/U/Unique Length-3 Palindromic Subsequences
1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change
1
+ // Runtime: 183 ms (Top 100.00%) | Memory: 52.8 MB (Top 44.44%)
1
2
var countPalindromicSubsequence = function ( s ) {
2
3
const charToIndices = { } ;
3
4
for ( let i = 0 ; i < s . length ; i ++ ) {
@@ -8,14 +9,14 @@ var countPalindromicSubsequence = function(s) {
8
9
charToIndices [ char ] = [ i ] ;
9
10
}
10
11
}
11
-
12
+
12
13
let count = 0 ;
13
14
for ( const currChar in charToIndices ) {
14
15
if ( charToIndices [ currChar ] . length < 2 ) continue ;
15
16
const currCharIndices = charToIndices [ currChar ] ;
16
17
const firstIndex = currCharIndices [ 0 ] ;
17
18
const lastIndex = currCharIndices [ currCharIndices . length - 1 ] ;
18
-
19
+
19
20
for ( const char in charToIndices ) {
20
21
const indices = charToIndices [ char ] ;
21
22
let lo = 0 ;
@@ -34,4 +35,4 @@ var countPalindromicSubsequence = function(s) {
34
35
}
35
36
}
36
37
return count ;
37
- } ;
38
+ } ;
You can’t perform that action at this time.
0 commit comments