Leetcode - Flip Game

My code:

public class Solution {
    public List<String> generatePossibleNextMoves(String s) {
        List<String> ret = new ArrayList<String>();
        if (s == null || s.length() == 0) {
            return ret;
        }
        char[] arr = s.toCharArray();
        for (int i = 0; i < arr.length - 1; i++) {
            if (arr[i] == arr[i + 1] && arr[i] == '+') {
                arr[i] = '-';
                arr[i + 1] = arr[i];
                ret.add(String.valueOf(arr));
                arr[i] = '+';
                arr[i + 1] = '+';
            }
        }
        return ret;
    }
}

简单题,没什么好说的。

Anyway, Good luck, Richardo! — 09/19/2016

    原文作者:Richardo92
    原文地址: https://www.jianshu.com/p/40cc2c0d2b4c#comments
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞