1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | public class Solution { char[] sChar; public boolean canWin(String s) { sChar = s.toCharArray(); return canWin(); } private boolean canWin(){ for (int i = 0; i < sChar.length-1; i++){ if (sChar[i] == '+' && sChar[i+1] == '+'){ sChar[i] = '-'; sChar[i+1] = '-'; boolean win = canWin(); sChar[i] = '+'; sChar[i+1] = '+'; if (!win) return true; } } return false; } } |
No comments:
Post a Comment