C++ solution in O(n) and O(1)
\n\n# Code\ncpp []\nclass Solution {\npublic:\n    bool canChange(string start, string target) {\n        int n = start.length();\n\n        int cnt = 0;\n     
\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    bool canChange(string start, string target) {\n        int n = start.length();\n\n        int cnt = 0;\n        int startcnt = 0;\n        int targetcnt = 0;\n        for (int i = 0;i < n;i ++) {\n            startcnt += (start[i] == \'R\');\n            cnt += (start[i] == \'R\');\n            cnt = (start[i] == \'L\') ? 0 : cnt;\n\n            if (target[i] == \'R\') {\n                targetcnt ++;\n                if (cnt == 0) return false;\n                cnt --;\n            }\n        }\n\n        if (startcnt != targetcnt) return false;\n\n        cnt = 0;\n        startcnt = 0;\n        targetcnt = 0;\n        for (int i = n - 1;i >= 0;i --) {\n            startcnt += (start[i] == \'L\');\n            cnt += (start[i] == \'L\');\n            cnt = (target[i] == \'R\') ? 0 : cnt;\n\n            if (target[i] == \'L\') {\n                targetcnt ++;\n                if (cnt == 0) return false;\n                cnt --;\n            }\n        }\n\n        return (startcnt == targetcnt);\n    }\n};\n```
['C++']