We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b7a4860 commit 1fb93a6Copy full SHA for 1fb93a6
scripts/algorithms/S/Swap Adjacent in LR String/Swap Adjacent in LR String.js
@@ -1,3 +1,4 @@
1
+// Runtime: 125 ms (Top 32.14%) | Memory: 42.9 MB (Top 73.21%)
2
/**
3
* @param {string} start
4
* @param {string} end
@@ -6,30 +7,30 @@
6
7
var canTransform = function(start, end) {
8
let i = 0;
9
let j = 0;
-
10
+
11
while (i < start.length || j < end.length) {
12
if (start[i] === 'X') {
13
i++;
14
continue;
15
}
16
17
if (end[j] === 'X') {
18
j++;
19
20
21
- // Breaking (1)
22
+ // Breaking (1)
23
if (start[i] !== end[j]) return false;
24
- // Breaking (2)
25
+ // Breaking (2)
26
if (start[i] === 'R' && i > j) return false;
27
- // Breaking (3)
28
+ // Breaking (3)
29
if (start[i] === 'L' && j > i) return false;
30
31
32
33
34
35
return true;
-};
36
+};
0 commit comments