Skip to content

Commit 7f94b97

Browse files
committed
[level 1] Title: 문자열 내 p와 y의 개수, Time: 0.06 ms, Memory: 73.7 MB -BaekjoonHub
1 parent f0dc06d commit 7f94b97

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

프로그래머스/1/12916. 문자열 내 p와 y의 개수/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### 성능 요약
66

7-
메모리: 74.1 MB, 시간: 0.04 ms
7+
메모리: 73.7 MB, 시간: 0.06 ms
88

99
### 구분
1010

@@ -16,7 +16,7 @@
1616

1717
### 제출 일자
1818

19-
2026년 06월 22일 07:45:04
19+
2026년 06월 24일 09:58:07
2020

2121
### 문제 설명
2222

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
class Solution {
22
boolean solution(String s) {
33
s = s.toUpperCase();
4-
int cnt = 0;
4+
int a = 0;
5+
int b = 0;
56
for (int i = 0; i < s.length(); i++) {
6-
if (s.charAt(i) == 'P') cnt++;
7-
else if (s.charAt(i) == 'Y') cnt--;
7+
char c = s.charAt(i);
8+
if (c == 'P') a++;
9+
if (c == 'Y') b++;
810
}
9-
return cnt == 0;
11+
return a == b;
1012
}
1113
}

0 commit comments

Comments
 (0)