java solution with comments
\npublic boolean swapAdjacentInLRString(String s, String e) {\n\tif(s.length() != e.length()) return false;\n\tint i = 0, j = 0;\n\tchar[] st = s.toCharArray();
```\npublic boolean swapAdjacentInLRString(String s, String e) {\n\tif(s.length() != e.length()) return false;\n\tint i = 0, j = 0;\n\tchar[] st = s.toCharArray();\n\tchar[] ed = e.toCharArray();\n\twhile(i < st.length || j < ed.length) {\n\t\t// only need to work with \'L\' and \'R\' so ignore \'X\'\n\t\twhile(i < st.length && st[i] == \'X\'){\n\t\t\t++i;\n\t\t}\n\t\twhile(j < ed.length && ed[j] == \'X\') {\n\t\t\t++j;\n\t\t}\n\t\t// both at end\n\t\tif(i == st.length && j == ed.length) {\n\t\t\treturn true;\n\t\t}\n\t\t// one of them at the end\n\t\tif(i == st.length || j == ed.length) {\n\t\t\treturn false;\n\t\t}\n\t\t// character not similar\n\t\tif(st[i] != ed[j]) return false;\n\t\t// if char is R we can go right only when i pointer doesn\'t exceed j pointer\n\t\tif(st[i] == \'R\' && i > j) return false;\n\t\t// if char is L we can go left only when i pointer exceed j pointer\n\t\tif(st[i] == \'L\' && i < j) return false;\n\t\ti++;\n\t\tj++;\n\t}\n\treturn true;\n}\n```
[]