반응형 [PCCP] Lv2: 이진 변환 반복하기(70129) 해설 문제- 문제 링크: 이진 변환 반복하기 해설- 자료구조: - 시간복잡도: (풀이과정)1) 2) 3) 4) 코드(C언어)solution 1)더보기#includesolution 2)더보기#include (C++)solution 1)- N: 주어진 수- while 문에서 N이 1이 될 때까지 2로 나누므로 시간 복잡도는 O(logN)- count() 호출시 필요한 시간 복잡도는 O(N)- 최종 시간 복잡도: O(NlogN)더보기#include #include #include #include using namespace std;vector solution(string s) { int transforms = 0; int removedZeros = 0; // s가 "1"이 될 때까지 계속 반복 .. 2024. 12. 25. 이전 1 다음 반응형