my easy understanding java soluction


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

Log in to reply
 

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