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 f572c37 commit 2bf236dCopy full SHA for 2bf236d
0777. Swap Adjacent in LR String.cpp
@@ -0,0 +1,32 @@
1
+// 777.✅ Swap Adjacent in LR String
2
+
3
+class Solution
4
+{
5
+public:
6
+ bool canTransform(string start, string end)
7
+ {
8
+ int i = 0, j = 0;
9
10
+ while (i < start.size() && j < end.size())
11
12
+ while (start[i] == 'X')
13
+ ++i;
14
+ while (end[j] == 'X')
15
+ ++j;
16
17
+ if (start[i] != end[j])
18
+ return 0;
19
+ else if (start[i] == 'R' && i > j)
20
21
+ else if (start[i] == 'L' && i < j)
22
23
24
25
+ }
26
+ while (i < start.size() && start[i] == 'X')
27
+ i++;
28
+ while (j < end.size() && end[j] == 'X')
29
+ j++;
30
+ return i == j;
31
32
+};
0 commit comments