Yawei.Huang188
BAN USERpublic boolean isValidPwd(String pwd){
return checkLength(pwd)&&checkSequence(pwd)&&checkChar(pwd);
}
public boolean checkLength(String pwd){
int len = pwd.length();
if(len<5||len>12) return false;
else return true;
}
public boolean checkChar(String pwd){
int alpha = 0, num=0;
for(int i=0;i<pwd.length();i++){
if(pwd.charAt(i)>='0'&&pwd.charAt(i)<='9') num++;
if(pwd.charAt(i)>='a'&&pwd.charAt(i)<='z') alpha++;
}
if(num>=1&&alpha>=1) return true;
else return false;
}
public boolean checkSequence(String pwd){
HashSet<String> hs = new HashSet<String>();
int len = pwd.length();
for(int i=0;i<len-1;i++){
for(int j=i+1;j<len;j++){
String str = pwd.substring(i,j);
if(!hs.contains(str)){
hs.add(str);
}else return false;
}
}
return true;
}
what if the grid has multi maximum path?
- Yawei.Huang188 June 25, 2015