File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 1
1
#include < iostream>
2
- #include < string>
3
2
#include < fstream>
4
3
#include < streambuf>
5
4
#include < stack>
6
5
7
6
using namespace std ;
8
7
9
- bool isPair (char a, char b) {
8
+ bool isPair (const char & a, const char & b) {
10
9
return abs (a - b) == 32 ;
11
10
}
12
11
13
- int part1 (string s) {
12
+ int part1 (const string & s) {
14
13
stack<char > st;
15
14
16
- int i= 0 , count = 0 ;
15
+ int i = 0 , count = 0 ;
17
16
while (s[i] != ' \n ' ){
18
17
if (st.empty () || !isPair (s[i], st.top ())) {
19
18
st.push (s[i]);
@@ -28,10 +27,10 @@ int part1(string s) {
28
27
return count;
29
28
}
30
29
31
- int part2 (string s, char ch) {
30
+ int part2 (const string & s, const char & ch) {
32
31
stack<char > st;
33
32
34
- int i= 0 , count = 0 ;
33
+ int i = 0 , count = 0 ;
35
34
while (s[i] != ' \n ' ){
36
35
if (s[i] == ch || s[i] == ch - 32 ) {
37
36
i++; continue ;
You can’t perform that action at this time.
0 commit comments