GitHub :
CodingTest/프로그래머스/2/132265. 롤케이크 자르기 at main · kwon1232/CodingTest
This is an auto push repository for Baekjoon Online Judge created with [BaekjoonHub](https://github.com/BaekjoonHub/BaekjoonHub). - kwon1232/CodingTest
github.com
#include <string>
#include <vector>
#include <map>
using namespace std;
int solution(vector<int> topping) {
int answer = 0;
map<int, int> m1, m2;
for(int i = 0; i < topping.size(); i++)
{
m1[topping[i]]++;
}
for(int i = 0; i < topping.size(); i++)
{
m1[topping[i]]--;
m2[topping[i]]++;
if(m1[topping[i]] == 0)
m1.erase(topping[i]);
if(m1.size() == m2.size())
answer++;
}
return answer;
}
문제 링크
https://school.programmers.co.kr/learn/courses/30/lessons/132265
'콘솔창 & 윈도우창 > 코딩 테스트' 카테고리의 다른 글
프로그래머스 LV.2 연속 부분 수열의 합의 개수 (0) | 2025.03.31 |
---|---|
프로그래머스 LV.3 야근 지수 (0) | 2025.03.31 |
프로그래머스 LV.2 예상 대진표 (0) | 2025.03.23 |
백준 실버4 1920 수 찾기 (1) | 2024.12.26 |
프로그래머스 LV.2 전화번호 목록 (2) | 2024.12.24 |