Problem: Strong Password Checker II

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: `"!@#$%^&*()-+"`.
* 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`.


Python solution:
import math
import itertools
import bisect
import collections
import string
import heapq
import functools
import sortedcontainers
from typing import List, Dict, Tuple, Iterator

class Solution:
  def strongPasswordCheckerII(self, password: str) -> bool:
    if len(password) < 8:
      return False
    if not any(c.islower() for c in password):
      return False
    if not any(c.isupper() for c in password):
      return False
    if not any(c.isdigit() for c in password):
      return False
    if not any("!@#$%^&*()-+".find(c) != -1 for c in password):
      return False
    return all(a != b for a, b in zip(password, password[1:]))


Java solution:
class Solution {
  public boolean strongPasswordCheckerII(String password) {
    if (password.length() < 8)
      return false;

    final boolean hasLowerCase = password.chars().anyMatch(c -> Character.isLowerCase(c));
    if (!hasLowerCase)
      return false;

    final boolean hasUpperCase = password.chars().anyMatch(c -> Character.isUpperCase(c));
    if (!hasUpperCase)
      return false;

    final boolean hasDigit = password.chars().anyMatch(c -> Character.isDigit(c));
    if (!hasDigit)
      return false;

    final boolean hasSpecial = password.chars().anyMatch(c -> "!@#$%^&*()-+".indexOf(c) != -1);
    if (!hasSpecial)
      return false;

    for (int i = 1; i < password.length(); ++i)
      if (password.charAt(i) == password.charAt(i - 1))
        return false;
    return true;
  }
}


C++ solution:
class Solution {
 public:
  bool strongPasswordCheckerII(string password) {
    if (password.length() < 8)
      return false;

    const bool hasLowerCase =
        ranges::any_of(password, [](const char c) { return islower(c); });
    if (!hasLowerCase)
      return false;

    const bool hasUpperCase =
        ranges::any_of(password, [](const char c) { return isupper(c); });
    if (!hasUpperCase)
      return false;

    const bool hasDigit =
        ranges::any_of(password, [](const char c) { return isdigit(c); });
    if (!hasDigit)
      return false;

    const bool hasSpecial = ranges::any_of(password, [](const char c) {
      return string("!@#$%^&*()-+").find(c) != string::npos;
    });
    if (!hasSpecial)
      return false;

    for (int i = 1; i < password.length(); ++i)
      if (password[i] == password[i - 1])
        return false;
    return true;
  }
};