Flip Game

https://leetcode.com/problems/flip-game/

  public List<String> generatePossibleNextMoves(String s) {
        List<String> res=new ArrayList<String>();
        if(s==null||s.length()<2){
            return res;
        }
        for(int i=0;i<=s.length()-2;i++){
            if(s.charAt(i)=='+'&&s.charAt(i)==s.charAt(i+1)){
                res.add(s.substring(0,i)+"--"+(i+2<s.length()?s.substring(i+2):""));
            }
        }
        return res;
    }

 

posted @ 2015-11-04 05:28  fifi努刷题  阅读(35)  评论(0)    收藏  举报