Move Pieces to Obtain a String | Java Solution
\nclass Solution {\n    public boolean canChange(String start, String target) {\n        int characs = 0; \n        for (int i=0;i<start.length();i++) \n       
```\nclass Solution {\n    public boolean canChange(String start, String target) {\n        int characs = 0; \n        for (int i=0;i<start.length();i++) \n        { \n            char ch = start.charAt(i);\n            if (ch != \'_\') \n                characs++; \n        } \n        for (int i=0;i<target.length();i++) \n        { \n            char ch = target.charAt(i);\n            if (ch != \'_\') \n                characs--; \n        } \n        if (characs != 0) \n            return false; \n        return compute(start, target); \n    } \n     \n    public boolean compute(String start, String target) \n    { \n        int LStart = 0, RStart = 0; \n        int LTarget = 0, RTarget = 0; \n        for (int i = 0; i < start.length(); i++) \n        { \n            char ch1 = start.charAt(i); \n            char ch2 = target.charAt(i); \n            if (ch1 == \'L\') \n                LStart++; \n            else if(ch1 == \'R\') \n                RStart++; \n            if (ch2 == \'L\') \n                LTarget++; \n            else if(ch2 == \'R\') \n                RTarget++; \n        } \n         \n        if (LStart != LTarget || RStart != RTarget) \n            return false; \n        \n        List<Integer> ar1 = new ArrayList<>(); \n        List<Integer> ar2 = new ArrayList<>(); \n         \n        for (int i = 0; i < start.length(); i++) \n        { \n            char ch = start.charAt(i);\n            if (ch != \'_\') { \n                ar1.add(i); \n            } \n            if (target.charAt(i) != \'_\') { \n                ar2.add(i); \n            } \n        } \n         \n        for (int i = 0; i < ar1.size(); i++) \n        { \n            if (start.charAt(ar1.get(i)) != target.charAt(ar2.get(i)))  \n                return false; \n            \n            if (start.charAt(ar1.get(i)) == \'L\') \n            { \n                if (ar1.get(i) < ar2.get(i)) \n                    return false; \n            } else \n            { \n                if (ar1.get(i) > ar2.get(i)) \n                    return false; \n            } \n        } \n        return true; \n\n    }\n}\n```
['Java']