MCPcopy Create free account
hub / github.com/Ayush7614/Daily-Coding-DS-ALGO-Practice / solve

Method solve

Hackerank/Java/Strong-password.java:33–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31 // The solution function to check the validity of the entered password is correct or not.
32
33 void solve()
34 {
35 String numbers = "0123456789",
36 lower_case = "abcdefghijklmnopqrstuvwxyz",
37 upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
38 special_characters = "!@#$%^&*()-+";
39 int n = ni();
40 char[] s = ns(n);
41 int need = 0;
42 int x = 0;
43 for(char c : s){
44 if(numbers.indexOf(c) >= 0)x |= 1;
45 if(lower_case.indexOf(c) >= 0)x |= 2;
46 if(upper_case.indexOf(c) >= 0)x |= 4;
47 if(special_characters.indexOf(c) >= 0)x |= 8;
48 }
49 need = 4-Integer.bitCount(x);
50 out.println(Math.max(6-n, need));
51 }
52
53 void run() throws Exception
54 {

Callers 1

runMethod · 0.95

Calls 2

niMethod · 0.95
nsMethod · 0.95

Tested by

no test coverage detected