Share my Java 1ms solution,very easy to understand

  • 0
    public class Solution {
        public List<String> generatePossibleNextMoves(String s) {
            List<String> rs = new ArrayList<>();
            for(int i=0;i<s.length()-1;i++){
                if(s.charAt(i)=='+' && s.charAt(i+1)=='+'){
                    String ss = s.substring(0,i)+"--"+s.substring(i+2);
            return rs;

Log in to reply

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