文章目录
- 题意
- 思路
- 代码
题意
题目链接
判断是否合法密码
思路
if
代码
class Solution {
public:bool strongPasswordCheckerII(string password) {if (password.size() < 8)return false;int visit = 0;for (size_t i = 0; i < password.size(); i++){char &ch = password[i];if ('a' <= ch && ch <= 'z')visit |= 1;else if ('A' <= ch && ch <= 'Z')visit |= (1 << 1);else if ('0' <= ch && ch <= '9')visit |= (1 << 2);else if (string("!@#$%^&*()-+").find(ch) != string::npos)visit |= (1 << 3);if (i > 0 && ch == password[i - 1])return false;}return visit == 0xf;}
};