You are viewing a single comment's thread. Return to all comments →
You don't need to pre-compile regex expressions if you are going to use them once. This is my solution:
static int minimumNumber(int n, String password) {
int count = 0; if(!password.matches(".*[a-z].*")) { count++; } if(!password.matches(".*[A-Z].*")) { count++; } if(!password.matches(".*[0-9].*")) { count++; } if(password.matches("[a-zA-Z0-9]*")) { count++; } int lengthDifference = 6 - password.length(); if(lengthDifference > 0 && count <= lengthDifference) { return lengthDifference; } return count; }
Seems like cookies are disabled on this browser, please enable them to open this website
Strong Password
You are viewing a single comment's thread. Return to all comments →
You don't need to pre-compile regex expressions if you are going to use them once. This is my solution:
static int minimumNumber(int n, String password) {