Simple Java one Pass O(N). Moving On A Track
Imagine 2 kinds of pawn moving on a track, left pawn and right pawn. You want to push all the left pawns to the left and all the right pawns to the right.\nThe 
Imagine 2 kinds of pawn moving on a track, left pawn and right pawn. You want to push all the left pawns to the left and all the right pawns to the right.\nThe right pawn will block all the left pawns from its right to move left, and the left pawn will block all the right pawns from its left to move right.\n```\nclass Solution {\n    public boolean canTransform(String start, String end) {\n        int L1 = 0, L2 = 0, R1 = 0, R2 = 0;\n        for (int i = 0; i < start.length(); i++) {\n            char c1 = start.charAt(i), c2 = end.charAt(i);\n\t\t\t\n            if (c1 == \'R\') {\n\t\t\t\t// if we encounter a R in first string, the number of L on its left is fixed, not more L can added to its left.\n                if (L1 != L2) return false;\n                R1++;\n            }else if (c1 == \'L\') {\n\t\t\t\t// if we encounter a L in first string, the number of R on its left is fixed, it can\'t decrease.\n                if (R1 != R2) return false;\n                L1++;\n            }\n            if (c2 == \'L\') {\n                L2++;\n            } else if (c2 == \'R\') {\n                R2++;\n            }\n            \n\t\t\t// L can\'t move right and R can\'t move left\n            if (L2 < L1 || R2 > R1) {\n                return false;\n            }\n        }\n        \n\t\t// for case like "XXXX" "LXXX"\n        return L1 == L2 && R1 == R2;\n    }\n}\n```
[]