Two Pointer | Easy | Fast | Commented
Thanks to koroja3877 for the answer, here is my explaination with comments for easy understanding.\n\n\tvar canChange = function (start, target) {\n\t\tlet lCou
Thanks to [koroja3877](https://leetcode.com/koroja3877/) for the answer, here is my explaination with comments for easy understanding.\n\n\tvar canChange = function (start, target) {\n\t\tlet lCount = 0;//count of l\'s in target, to be consumed later in start\n\t\tlet rCount = 0;//count of r\'s in start, to be consumed later in target\n\n\t\tfor (let i = 0; i < start.length; i++) {\n\t\t\tif (start[i] === "R") rCount++;//add r to count\n\t\t\tif (start[i] === "L") lCount--;//remove l from count\n\n\t\t\tif (target[i] === "L" && rCount > 0) return false;//if L in start is blocked by R\n\t\t\tif (start[i] === "L" && rCount > 0) return false;//if there is an unsetteled R in start\n\n\t\t\tif (target[i] === "L") lCount++;//add l to count\n\t\t\tif (target[i] === "R") rCount--;//remove r from count\n\n\t\t\tif (lCount< 0 || rCount < 0) return false;//check if the requirements are less than available\n\t\t}\n\t\treturn !lCount && !rCount;//count should return to zero as all L and R are consumed\n\t};
['Two Pointers', 'JavaScript']