File tree 1 file changed +0
-6
lines changed
src/main/java/g0701_0800/s0726_number_of_atoms
1 file changed +0
-6
lines changed Original file line number Diff line number Diff line change @@ -24,12 +24,10 @@ public String countOfAtoms(String formula) {
24
24
Map <String , Integer > count = new HashMap <>();
25
25
for (int i = formula .length () - 1 ; i >= 0 ; --i ) {
26
26
char c = formula .charAt (i );
27
-
28
27
if (c == '(' ) {
29
28
product /= mlrStack .pop ();
30
29
continue ;
31
30
}
32
-
33
31
int rank = 1 ;
34
32
int mlr = 0 ;
35
33
while (isDigit (c )) {
@@ -42,21 +40,17 @@ public String countOfAtoms(String formula) {
42
40
}
43
41
mlrStack .push (mlr );
44
42
product *= mlr ;
45
-
46
43
if (c == ')' ) {
47
44
continue ;
48
45
}
49
-
50
46
StringBuilder atom = new StringBuilder ();
51
47
while (isLower (c )) {
52
48
atom .insert (0 , c );
53
49
c = formula .charAt (--i );
54
50
}
55
51
atom .insert (0 , c );
56
52
String name = atom .toString ();
57
-
58
53
count .put (name , count .getOrDefault (name , 0 ) + product );
59
-
60
54
product /= mlrStack .pop ();
61
55
}
62
56
List <String > atomList = new ArrayList <>(count .keySet ());
You can’t perform that action at this time.
0 commit comments