https://school.programmers.co.kr/learn/courses/30/lessons/132265
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
using namespace std;
int solution(vector<int> topping) {
map<int, int> a, b;
std::for_each(topping.begin(), topping.end(), [&](const auto& t) { ++b[t]; });
return std::accumulate(topping.begin(), topping.end(), 0, [&](auto acc, const auto& t) {
++a[t], --b[t];
if (b[t] == 0) b.erase(t);
return (a.size() == b.size()) ? acc + 1 : acc;
});
}
[unrated] Title: 롤케이크 자르기, Time: 159.15 ms, Memory: 37 MB -BaekjoonHub · developeSHG/Algorithm-Baekjoon_Programme
developeSHG committed Jul 21, 2023
github.com
'Coding Test > Programmers' 카테고리의 다른 글
[Programmers] (정렬) Lv 2. 가장 큰 수 (0) | 2023.07.24 |
---|---|
[Programmers] (스택/큐) Lv 2. 다리를 지나는 트럭 (0) | 2023.07.23 |
[Programmers] (월간 코드 챌린지 시즌2) Lv 2. 2개 이하로 다른 비트 (0) | 2023.07.21 |
[Programmers] Lv 2. 숫자 변환하기 (0) | 2023.07.20 |
[Programmers] Lv 2. 2 x N 타일링 (0) | 2023.07.19 |
댓글