python/java 2 pointers
\tclass Solution:\n\t\tdef canChange(self, start: str, target: str) -> bool:\n\t\t\tif start.count("") != target.count(""):\n\t\t\t\treturn False\n\t\t\ti = 0\n
\tclass Solution:\n\t\tdef canChange(self, start: str, target: str) -> bool:\n\t\t\tif start.count("_") != target.count("_"):\n\t\t\t\treturn False\n\t\t\ti = 0\n\t\t\tj = 0\n\t\t\twhile i < len(start) and j < len(target):\n\t\t\t\tif start[i] == "_":\n\t\t\t\t\ti += 1\n\t\t\t\t\tcontinue\n\t\t\t\tif target[j] == "_":\n\t\t\t\t\tj += 1\n\t\t\t\t\tcontinue\n\t\t\t\tif start[i] != target[j]:\n\t\t\t\t\treturn False\n\t\t\t\tif start[i] == "L" and i < j:\n\t\t\t\t\treturn False\n\t\t\t\tif start[i] == "R" and i > j:\n\t\t\t\t\treturn False\n\t\t\t\ti += 1\n\t\t\t\tj += 1\n\t\t\treturn True\n\n\n\tclass Solution {\n\t\tpublic boolean canChange(String start, String target) {\n\t\t\tint cnt1 = 0;\n\t\t\tint cnt2 = 0;\n\t\t\tfor (int i = 0; i < start.length(); i ++) {\n\t\t\t\tif (start.charAt(i) == \'_\') {\n\t\t\t\t\tcnt1 ++;\n\t\t\t\t}\n\t\t\t\tif (target.charAt(i) == \'_\') {\n\t\t\t\t\tcnt2 ++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (cnt1 != cnt2) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tint i = 0;\n\t\t\tint j = 0;\n\t\t\twhile (i < start.length() && j < target.length()) {\n\t\t\t\tif (start.charAt(i) == \'_\') {\n\t\t\t\t\ti ++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (target.charAt(j) == \'_\') {\n\t\t\t\t\tj ++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (start.charAt(i) != target.charAt(j)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (start.charAt(i) == \'L\' && i < j) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (start.charAt(i) == \'R\' && i > j) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\ti ++;\n\t\t\t\tj ++;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t}
[]