[C++] || space: O(1) time:O(n) || Easy Solution + Explanation
Approach:\n  Let us think of a naive approach:\n\t We realise that if we see a L in target => our L in start string should be after the  L in target string.  We
**Approach:**\n*  Let us think of a naive approach:\n\t* We realise that if we see a `L` in target => our `L` in start string should be after the  `L` in target string.  We also realise all the letter b/w the start index till the target index of `L` should be `_` so that `L` in start string can move left back and reach its target location.\n\t* Similarly, if we see a `R` in target => our `R` in start string should be before the  `R` in target string. Also all the indices b/w these location should contain `_`\n\t* We could intially maybe store all indices of `L` and `R` in target and start strings and check if these constraints are met. But this will be nearly O(n^2) and exceeded time limit.\n\n* Now let us see how we can solve in O(n), an optimised approach:\n\t* let us iterate through the start and target string.\n\t* if we see a `L` in target string we update the number of `L` s we need to find later on in the start string in a variable `left` . We realise if before we exhaust all `L` s that we need to find in start string, if we encounter any charecter except `_` and `L` which is basically `R` we cannot move `L` and therefore not reach target string.\n\t* similarly if we see a `R` in start string, we update the number of `R` s we need to find later on in the target string in a variable `right` . we should not encounter an `L` before we exhaust all `R`. \n\t* at the end we make sure we have exhausted all `L` and `R` . We keep this extra check in case we have more `L` or `R` in either strings.\n```\nclass Solution {\npublic:\n    bool canChange(string start, string target) {\n       int left = 0;\n       int right = 0;\n       int l=0;\n       int r=0;\n       int n = start.size();\n        \n       for(int i=0; i<n; i++){\n           if(target[i]==\'L\') left++;\n           if(start[i]==\'R\')  right++;\n           \n           if(left && start[i]==\'R\') return 0;\n           if(!left && start[i]==\'L\') return 0;\n           if(left && start[i]==\'L\') left--;\n\n           \n           if(right && target[i]==\'L\') return 0;\n           if(!right && target[i]==\'R\') return 0;\n           if(right && target[i]==\'R\') right--;   \n       }\n        \n        if(!right && !left){\n            return 1;\n        }\n        return 0;\n    }\n};\n```\nHope this helps!
['String', 'Greedy', 'C', 'C++']