C++ || O(N) time, O(1) space intuitive and easy to understand
The Idea is to iterate both strings skipping and counting how many  \'underscore char\' we find and try to see if character can be moved.\nWe can hit 3 cases:\n
The Idea is to iterate both strings skipping and counting how many  \'underscore char\' we find and try to see if character can be moved.\nWe can hit 3 cases:\n1 we have different char on start and on target string...ok we are done..we can\'t continue\n2 we have L on both strings...we need to check if the position where we found this character on start string is smaller then the position where we found the same char on target. If this is the case we are done as we can\'t move a L char to the right in order to to the matching.\n3 Same of point 2 but with char R and this time the failure condition is that index on string s is bigger than index on target (as we can\'t move an R to the left\nwhen we exit from the while loop we have to check if the number of blak is equal for both string...this is neede for cases like\n"_L"\n"LL"\nas the first L can be moved to the left...but then we do not have a second L to match...\nI hope it helps\n\n```\nclass Solution {\npublic:\n    bool canChange(string start, string target) {\n        int i = 0;\n        int j = 0;\n        int cnt_s = 0;\n        int cnt_t = 0;\n        if(start.length() != target.length())\n            return false;\n        while(i < start.length() || j < target.length()) {\n            while(i < start.length() && start[i] == \'_\') {\n                ++i;\n                ++cnt_s;\n            }\n            while(j < target.length() && target[j] == \'_\') {\n                ++j;\n                ++cnt_t;\n            }\n            if(start[i] == \'L\' && target[j] == \'L\')\n                if(i< j)\n                    return false;\n            if(start[i] == \'R\' && target[j] == \'R\')\n                if(i > j)\n                    return false;\n            if(start[i] != target[j])\n                return false;\n            ++i;\n            ++j;\n        }\n        return cnt_s == cnt_t;\n    }\n};\n```
['Two Pointers']