Java two-pointers solution, O(n) time and O(1) space
the number and order of pieces must not change\n2. for a piece \'L\', its index in the target string must be equal to or less than its index in the start string
1. the number and order of pieces must not change\n2. for a piece \'L\', its index in the target string must be equal to or less than its index in the start string\n3. for a piece \'R\', its index in the target string must be equal to or greater than its index in the start string\n```\nclass Solution {\n    public boolean canChange(String start, String target) {\n        int i = 0, j = 0, n = start.length();\n        while(i < n && j < n) {\n            while(i < n && start.charAt(i) == \'_\') i++;\n            while(j < n && target.charAt(j) == \'_\') j++;\n            if(i == n && j == n) return true;\n            if(i == n || j == n || start.charAt(i) != target.charAt(j)) return false;\n            if(start.charAt(i) == \'L\' && i < j) return false;\n            if(start.charAt(i) == \'R\' && i > j) return false;\n            i++;\n            j++;\n        }\n        return true;\n    }\n}\n```
['Two Pointers', 'Java']