We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e498dd6 commit aea84acCopy full SHA for aea84ac
scripts/algorithms/L/Letter Case Permutation/Letter Case Permutation.js
@@ -1,11 +1,12 @@
1
+// Runtime: 99 ms (Top 77.76%) | Memory: 45.1 MB (Top 64.02%)
2
const sliceRemaining = (s) => s.slice(1, s.length);
3
4
var letterCasePermutation = function(s) {
5
let output = [];
-
6
+
7
const backtracking = (current, remaining) => {
8
if (!remaining.length) return output.push(current);
9
10
if (/^[0-9]+$/i.test(remaining[0])) {
11
current += remaining[0];
12
backtracking(current, sliceRemaining(remaining));
@@ -16,6 +17,6 @@ var letterCasePermutation = function(s) {
16
17
}
18
19
backtracking('', s);
20
21
return output;
-};
22
+};
0 commit comments