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 631ba8e commit e838742Copy full SHA for e838742
2337-move-pieces-to-obtain-a-string.js
@@ -0,0 +1,31 @@
1
+/**
2
+ * @param {string} start
3
+ * @param {string} target
4
+ * @return {boolean}
5
+ */
6
+const canChange = function(start, target) {
7
+ const n=target.length;
8
+ let i=0,j=0;
9
+ while(i<=n && j<=n){
10
+
11
+ while(i<n && target[i]==='_') i++;
12
+ while(j<n && start[j]==='_') j++;
13
14
+ if(i===n || j===n){
15
+ return i===n && j===n;
16
+ }
17
18
+ if(target[i]!==start[j]) return false;
19
20
+ if(target[i]==='L'){
21
+ if(j<i) return false;
22
23
+ else{
24
+ if(i<j) return false;
25
26
27
+ i++;
28
+ j++;
29
30
+ return true;
31
+};
0 commit comments