We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
intminimumNumber(intn,stringpassword){// Return the minimum number of characters to make the password strongboolUP=0,down=0,digit=0,special=0;unsignedintresult1=4,res2=0;for(inti=0;i<n;i++){if(password.at(i)<='z'andpassword.at(i)>='a'){down=1;}if(password.at(i)<='9'andpassword.at(i)>='0'){digit=1;}if(password.at(i)<='Z'andpassword.at(i)>='A'){UP=1;}if((password.at(i)<='+'andpassword.at(i)>='!')or(password.at(i)=='^')or(password.at(i)=='-')or(password.at(i)=='@')){special=1;}}res2=UP+down+digit+special;if(n>=6){result1-=res2;}if(n==5andres2==0){result1=res2+1;}if(n==5andres2>=1){result1=result1-res2;}if(n==5andres2==4){result1=6-n;}if(n==4){result1=res2+2;}if(n==4andres2>=2){result1=res2;}if(n==4andres2>=3){result1=6-n;}if(n<=3){result1=6-n;}returnresult1;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Join us
Create a HackerRank account
Be part of a 26 million-strong community of developers
Please signup or login in order to view this challenge
Strong Password
You are viewing a single comment's thread. Return to all comments →
c++