문제를 풀기 위해서 LRU알고리즘을 알고 있어야 합니다.LRU알고리즘은 널리 알려져 있고 어렵지 않으니 검색해서 확인해보시면 금방 이해가 가실 겁니다. 문제 조건에서 대소문자를 구분하지 않는데, 저는 전부 대문자로 만들어 문제를 해결했습니다.캐시 사이즈가 0일 때 조건을 만드는 것만 주의해주시면 금방 해결하실 수 있는 문제입니다. #include #include #include #include using namespace std; int solution(int cacheSize, vector cities) { int answer = 0; string cache[30]; int cachepoint = 0; bool hitormiss = false; //캐시 사이즈가 0이면 다음 과정을 할 필요가 없음 if..
OR연산과 10진수를 2진수로 변환하는 개념을 알고 있으면 쉽게 풀 수 있는 문제입니다. #include #include #include #include using namespace std; vector solution(int n, vector arr1, vector arr2) { vector answer; string tmp; string tmp2; int a; int b; for (int i = 0;i < n;i++) { a = arr1.at(i) | arr2.at(i); tmp = ""; tmp2 = ""; for (int j = 0;j < n;j++) { b = a % 2; if (b == 1) { tmp += "#"; } else { tmp += " "; } a = a / 2; } for (in..