A password is said to be strong if it satisfies all the following criteria:


	It has at least 8 characters.
	It contains at least one lowercase letter.
	It contains at least one uppercase letter.
	It contains at least one digit.
	It contains at least one special character. The special characters are the characters in the following string: "!@#$%^&amp;*()-+".
	It does not contain 2 of the same character in adjacent positions (i.e., "aab" violates this condition, but "aba" does not).


Given a string password, return true if it is a strong password. Otherwise, return false.

&nbsp;
Example 1:

Input: password = "IloveLe3tcode!"
Output: true
Explanation: The password meets all the requirements. Therefore, we return true.


Example 2:

Input: password = "Me+You--IsMyDream"
Output: false
Explanation: The password does not contain a digit and also contains 2 of the same character in adjacent positions. Therefore, we return false.


Example 3:

Input: password = "1aB!"
Output: false
Explanation: The password does not meet the length requirement. Therefore, we return false.

&nbsp;
Constraints:


	1 &lt;= password.length &lt;= 100
	password consists of letters, digits, and special characters: "!@#$%^&amp;*()-+".


class Solution:
    def strongPasswordCheckerII(self, pwd: str) -> bool:
        return (
            len(pwd) > 7
            and max(len(list(p[1])) for p in groupby(pwd)) == 1
            and reduce(
                lambda a, b: a | (1 if b.isdigit() else 2 if b.islower() else 4 if b.isupper() else 8), pwd, 0
            ) == 15
        )
class Solution {
    public boolean strongPasswordCheckerII(String password) {
           HashSet<Integer> intAscii = new HashSet<>();
        String specialCharacters = "!@#$%^&*()-+";
        for (int i = 0; i < specialCharacters.length(); i++) {
            int ascii = specialCharacters.charAt(i);
            intAscii.add(ascii);
        }
        
        if(password.length() < 8){
            return false;
        }
        boolean small = false;
        boolean large = false;
        boolean numbers = false;
        boolean specialChars = false;
        for(int i = 0 ; i < password.length() ; i++){
            int ascii = (int)(password.charAt(i));
            if(ascii <= 90 && ascii>=65){
                large = true;
            }
                if(ascii <= 122 && ascii>=97){
                small = true;
            }
            if(ascii <=57 && ascii >=48){
                numbers = true;
            }
            if(intAscii.contains(ascii)){
                specialChars = true;
            }
            if(i> 0 && password.charAt(i)== password.charAt(i-1)){
                return false;
            }
        }
        if(large == false || small == false || numbers == false || specialChars ==false){
            return false;
        }
        return true;
    }
}
class Solution {
public:
    bool strongPasswordCheckerII(string password) {
		if(password.size() < 8) //8 char length
            return false;
			
        bool lower = 0, upper = 0;
        bool digit = 0, special = 0;
		
        for(int i=0; i<password.size(); i++){ //check rest conditions
            if(i>0 && password[i] == password[i-1])   //check duplicate
				return false; 
             
			if(password[i] >=65 && password[i] <=90)  upper = 1;  //uppercase
			else if(password[i] >=97 && password[i] <=122)   lower = 1;   //lowercase
			else if(password[i] >=48 && password[i] <=57)       digit = 1;   //digit
			else     //special char
                special = 1;
        }
        
        if(upper && lower && digit && special)
            return true;
        return false;
    }
};
const checkLen = (password) => password.length >= 8;

const checkSmallLetter = (password) => {
    for(let i=0;i<password.length;i++){
        const ind = password.charCodeAt(i);
        if(ind > 96 && ind < 123){
            return true;
        }
    }
    return false;
}

const checkCapitalLetter = (password) => {
    for(let i=0;i<password.length;i++){
        const ind = password.charCodeAt(i);
        if(ind > 64 && ind < 91){
            return true;
        }
    }
    return false;
}

const checkDigit = (password) => {
    for(let i=0;i<password.length;i++){
        const ind = password.charCodeAt(i);
        if(ind > 47 && ind < 58){
            return true;
        }
    }
    return false;
}

const checkSpecialChar = (password) => {
    const str = "!@#$%^&*()-+";
     for(let i=0;i<str.length;i++){
       if(password.includes(str[i])) return true;
    }
    return false;
}

const checkAdjacentMatches = (password) => {
    for(let i=1;i<password.length;i++){
        if(password[i] === password[i-1]) return false;
    }
    return true;
}


var strongPasswordCheckerII = function(password) {
    const lenValidity = checkLen(password);
    const smallLetterValidity = checkSmallLetter(password);    
    const capitalLetterValidity = checkCapitalLetter(password);
    const digitValidity = checkDigit(password);
    const specialCharValidity = checkSpecialChar(password);
    const adjacentMatchesValidity = checkAdjacentMatches(password);
        
    const passwordIsStrong = lenValidity && smallLetterValidity && capitalLetterValidity && digitValidity && specialCharValidity && adjacentMatchesValidity;
  
    return passwordIsStrong;
};
Strong Password Checker II