본문 바로가기
반응형

알고리즘33

[프로그래머스 - 완전탐색] 숫자 야구 📄 [완전탐색] 숫자 야구 C++ Source Code #include #include #include #include using namespace std; #define INT_PAIR pair #define CUS_PAIR pair #define START 123 #define END 987 const bool findDigit(const INT_PAIR condition, const string target, const string match) { INT_PAIR conds = make_pair(0, 0); for (int ii = 0; ii < target.size(); ii++) { for (int jj = 0; jj < match.size(); jj++) { // Case Find Strike.. 2019. 4. 5.
[프로그래머스 - 정렬] K번째수 📄 [정렬] K번째수 C++ Source Code #include #include #include using namespace std; const int findTarget(const vector & arr, const int left, const int right, const int target) { vector bucket = vector(arr.begin() + left, arr.begin() + right); std::sort(bucket.begin(), bucket.end()); return bucket[target]; } vector solution(vector array, vector commands) { vector answer; for (const auto command : command.. 2019. 4. 5.
[프로그래머스 - 정렬] H-Index 📄 [정렬] H-Index Swift Source Code import Foundation // MARK: - https://en.wikipedia.org/wiki/H-index func solution(_ citations:[Int]) -> Int { let length = citations.count // MARK: - First we order the values of f from the largest to the lowest value. (DESC - 오름차순) let paper = citations.sorted { $0 > $1 } // MARK: - we look for the last position in which f is greater than or equal to the position.. 2019. 4. 5.
[프로그래머스 - 탐색] 네트워크 카테고리 (Category) 작성 날짜 (Write Date) 최근 수정 날자 (Recent Write Date) 작성자 (Writer) Algorithm 2019-04-05 00:25 2021.04.19. 10:58:54 Dev.Yang [문제설명] 네트워크란 컴퓨터 상호 간에 정보를 교환할 수 있도록 연결된 형태를 의미합니다. 예를 들어, 컴퓨터 A와 컴퓨터 B가 직접적으로 연결되어있고, 컴퓨터 B와 컴퓨터 C가 직접적으로 연결되어 있을 때 컴퓨터 A와 컴퓨터 C도 간접적으로 연결되어 정보를 교환할 수 있습니다. 따라서 컴퓨터 A, B, C는 모두 같은 네트워크 상에 있다고 할 수 있습니다. 컴퓨터의 개수 n, 연결에 대한 정보가 담긴 2차원 배열 computers가 매개변수로 주어질 때, 네트워크의.. 2019. 4. 5.
반응형