1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| public boolean strongPasswordCheckerII(String password) { int len = password.length(); int[] flag = new int[4]; char[] str = password.toCharArray(); if(len < 8){ return false; } for(int i = 0; i < len; i++){ if(flag[0] == 0 && str[i] >= 'a' && str[i] <= 'z'){ flag[0] = 1; } if(flag[1] == 0 && str[i] >= 'A' && str[i] <= 'Z'){ flag[1] = 1; } if(flag[2] == 0 && str[i] >= '0' && str[i] <= '9'){ flag[2] = 1; } if(flag[3] == 0 && (str[i] == '!' || str[i] == '@' || str[i] == '#' || str[i] == '$' || str[i] == '%' || str[i] == '^' || str[i] == '&' || str[i] == '*' || str[i] == '(' || str[i] == ')' || str[i] == '-' || str[i] == '+')){ flag[3] = 1; } if(i+1 < len && str[i] == str[i+1]){ return false; } } if(flag[0] == 1 && flag[1] == 1 && flag[2] == 1 && flag[3] == 1){ return true; }else{ return false; } }
|