Java concise solution.


  • 2
    C
    public List<String> generatePossibleNextMoves(String s) {
        List<String> ret = new ArrayList<>();
        for (int i=0; i<s.length()-1; i++)
            if (s.substring(i,i+2).equals("++"))
                ret.add(s.substring(0,i)+"--"+s.substring(i+2));
        return ret;
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.