We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ef4e10d commit 7fef774Copy full SHA for 7fef774
LiiNi-coder/202511/06 PGM 롤케이크 자르기.md
@@ -0,0 +1,30 @@
1
+```java
2
+import java.util.*;
3
+
4
+class Solution {
5
+ public int solution(int[] toppings) {
6
+ int answer=0;
7
+ HashMap<Integer, Integer> r = new HashMap<>();
8
+ for(int topping: toppings){
9
+ if(!r.containsKey(topping)){
10
+ r.put(topping, 0);
11
+ }
12
+ r.put(topping, r.get(topping)+1);
13
14
+ HashMap<Integer, Integer> l = new HashMap<>();
15
16
+ if(!l.containsKey(topping)){
17
+ l.put(topping, 0);
18
19
+ l.put(topping, l.get(topping)+1);
20
+ r.put(topping, r.get(topping)-1);
21
+ if(r.get(topping) == 0)
22
+ r.remove(topping);
23
+ if(l.size() == r.size())
24
+ answer++;
25
26
+ return answer;
27
28
29
+}
30
+```
0 commit comments