본문 바로가기
반응형

프로그래머스28

[프로그래머스 - 정렬] 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.
[프로그래머스 - 탐색] 여행경로 📄 [탐색] 여행경로 C++ Source Code #include #include #include #include using namespace std; #define ICN "ICN" #define STRING_VECTOR vector void findTripRoute(const int depth, const int length, const string airport, vector & visited, vector & answer, vector bucket, STRING_VECTOR & tickets) { bucket.push_back(airport); // MARK: - 주어진 항공권은 모두 사용해야 합니다. (즉, DFS의 깊이와 주어진 항공권의 크기와 같은 경우가 모든 항공권을 사용한 경우다.) if.. 2019. 4. 5.
반응형