Skip to content

Commit f87618e

Browse files
authored
Update README.md
1 parent 6ceab9a commit f87618e

File tree

1 file changed

+9
-9
lines changed
  • solution/0700-0799/0726.Number of Atoms

1 file changed

+9
-9
lines changed

solution/0700-0799/0726.Number of Atoms/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,25 +104,25 @@ class Solution {
104104
int[] stack = new int[1000];
105105
int top = 0, multiplier = 1, freq = 0;
106106
char[] c = formula.toCharArray();
107-
for(int i = c.length - 1; i >= 0; i--) {
108-
if(c[i] >= 'a' && c[i] <= 'z') {
107+
for (int i = c.length - 1; i >= 0; i--) {
108+
if (c[i] >= 'a' && c[i] <= 'z') {
109109
int end = i--;
110-
while(i >= 0 && c[i] >= 'a' && c[i] <= 'z') i--;
110+
while (i >= 0 && c[i] >= 'a' && c[i] <= 'z') i--;
111111
String key = new String(c, i, end - i + 1);
112112
map.put(key, map.getOrDefault(key, 0) + Math.max(freq, 1) * multiplier);
113113
freq = 0;
114-
} else if(c[i] >= 'A' && c[i] <= 'Z') {
114+
} else if (c[i] >= 'A' && c[i] <= 'Z') {
115115
String key = new String(c, i, 1);
116116
map.put(key, map.getOrDefault(key, 0) + Math.max(freq, 1) * multiplier);
117117
freq = 0;
118-
} else if(c[i] >= '0' && c[i] <= '9') {
118+
} else if (c[i] >= '0' && c[i] <= '9') {
119119
freq = c[i] - '0';
120120
int p = 10;
121-
while(i-1 >= 0 && c[i-1] >= '0' && c[i-1] <= '9') {
121+
while (i - 1 >= 0 && c[i - 1] >= '0' && c[i - 1] <= '9') {
122122
freq += p * (c[--i] - '0');
123123
p *= 10;
124124
}
125-
} else if(c[i] == ')') {
125+
} else if (c[i] == ')') {
126126
stack[top++] = multiplier;
127127
multiplier *= Math.max(freq, 1);
128128
freq = 0;
@@ -133,10 +133,10 @@ class Solution {
133133
List<String> keys = new ArrayList<>(map.keySet());
134134
Collections.sort(keys);
135135
StringBuilder sb = new StringBuilder();
136-
for(String key: keys) {
136+
for (String key : keys) {
137137
sb.append(key);
138138
int f = map.get(key);
139-
if(f > 1) sb.append(f);
139+
if (f > 1) sb.append(f);
140140
}
141141
return sb.toString();
142142
}

0 commit comments

Comments
 (0)