1 parent f0dc06d commit 7f94b97Copy full SHA for 7f94b97
2 files changed
프로그래머스/1/12916. 문자열 내 p와 y의 개수/README.md
@@ -4,7 +4,7 @@
4
5
### 성능 요약
6
7
-메모리: 74.1 MB, 시간: 0.04 ms
+메모리: 73.7 MB, 시간: 0.06 ms
8
9
### 구분
10
@@ -16,7 +16,7 @@
16
17
### 제출 일자
18
19
-2026년 06월 22일 07:45:04
+2026년 06월 24일 09:58:07
20
21
### 문제 설명
22
프로그래머스/1/12916. 문자열 내 p와 y의 개수/문자열 내 p와 y의 개수.java
@@ -1,11 +1,13 @@
1
class Solution {
2
boolean solution(String s) {
3
s = s.toUpperCase();
- int cnt = 0;
+ int a = 0;
+ int b = 0;
for (int i = 0; i < s.length(); i++) {
- if (s.charAt(i) == 'P') cnt++;
- else if (s.charAt(i) == 'Y') cnt--;
+ char c = s.charAt(i);
+ if (c == 'P') a++;
+ if (c == 'Y') b++;
}
- return cnt == 0;
11
+ return a == b;
12
13
0 commit comments