반응형 [PCCP] Lv2: 롤케이크 자르기(132265) 해설 문제- 문제 링크: 롤케이크 자르기 코드(C언어)solution 1)더보기#includesolution 2)더보기#include (C++)solution 1)- N: topping의 길이- topping의 길이만큼 반복문을 수행하므로 시간 복잡도는 O(N)- 내부 연산들은 모두 O(1)- 최종 시간 복잡도: O(N)더보기#include #include #include #include using namespace std;int solution(vector topping) { int answer = 0; // 남아있는 각 토핑의 개수 unordered_map topping_cnt; // 절반에 속한 토핑의 종류 unordered_set half_topping; // 카운터에 각 토핑의 개수를 저장.. 2024. 12. 25. 이전 1 다음 반응형