Coding Test
-
[프로그래머스] 연속된 부분 수열의 합 Java, c++, pythonCoding Test/programmers 2023. 6. 28. 12:29
문제 설명 비내림차순으로 정렬된 수열이 주어질 때, 다음 조건을 만족하는 부분 수열을 찾으려고 합니다. 기존 수열에서 임의의 두 인덱스의 원소와 그 사이의 원소를 모두 포함하는 부분 수열이어야 합니다. 부분 수열의 합은 k입니다. 합이 k인 부분 수열이 여러 개인 경우 길이가 짧은 수열을 찾습니다. 길이가 짧은 수열이 여러 개인 경우 앞쪽(시작 인덱스가 작은)에 나오는 수열을 찾습니다. 수열을 나타내는 정수 배열 sequence와 부분 수열의 합을 나타내는 정수 k가 매개변수로 주어질 때, 위 조건을 만족하는 부분 수열의 시작 인덱스와 마지막 인덱스를 배열에 담아 return 하는 solution 함수를 완성해주세요. 이때 수열의 인덱스는 0부터 시작합니다. 문제 바로가기 제한 사항 5 ≤ sequenc..
-
[프로그래머스] 요격시스템 c++, Java, pythonCoding Test/programmers 2023. 6. 26. 17:13
문제 설명 문제 바로가기 A 나라가 B 나라를 침공하였습니다. B 나라의 대부분의 전략 자원은 아이기스 군사 기지에 집중되어 있기 때문에 A 나라는 B 나라의 아이기스 군사 기지에 융단폭격을 가했습니다. A 나라의 공격에 대항하여 아이기스 군사 기지에서는 무수히 쏟아지는 폭격 미사일들을 요격하려고 합니다. 이곳에는 백발백중을 자랑하는 요격 시스템이 있지만 운용 비용이 상당하기 때문에 미사일을 최소로 사용해서 모든 폭격 미사일을 요격하려 합니다. A 나라와 B 나라가 싸우고 있는 이 세계는 2 차원 공간으로 이루어져 있습니다. A 나라가 발사한 폭격 미사일은 x 축에 평행한 직선 형태의 모양이며 개구간을 나타내는 정수 쌍 (s, e) 형태로 표현됩니다. B 나라는 특정 x 좌표에서 y 축에 수평이 되도록 ..
-
[프로그래머스] 여행경로 c++Coding Test/programmers 2023. 5. 23. 09:53
문제 설명 주어진 항공권을 모두 이용하여 여행경로를 짜려고 합니다. 항상 "ICN" 공항에서 출발합니다. 항공권 정보가 담긴 2차원 배열 tickets가 매개변수로 주어질 때, 방문하는 공항 경로를 배열에 담아 return 하도록 solution 함수를 작성해주세요. 제한 사항 모든 공항은 알파벳 대문자 3글자로 이루어집니다. 주어진 공항 수는 3개 이상 10,000개 이하입니다. tickets의 각 행 [a, b]는 a 공항에서 b 공항으로 가는 항공권이 있다는 의미입니다. 주어진 항공권은 모두 사용해야 합니다. 만일 가능한 경로가 2개 이상일 경우 알파벳 순서가 앞서는 경로를 return 합니다. 모든 도시를 방문할 수 없는 경우는 주어지지 않습니다. 입출력 예 tickets return [["ICN..
-
[HackerRank] Simple Text Editor c++Coding Test/HackerRank 2023. 5. 17. 09:46
Problem Simple Text Editor | HackerRank Implement a simple text editor and perform some number of operations. www.hackerrank.com Sample Input STDIN Function ----- -------- 8 Q = 8 1 abc ops[0] = '1 abc' 3 3 ops[1] = '3 3' 2 3 ... 1 xy 3 2 4 4 3 1 Sample Output c y a Explanation Initially, S is empty. The following sequence of 8 operations are described below: Solutions stack을 사용하여 푸는 문제 유형입니다. 4..
-
[HackerRank] Balanced Brackets c++Coding Test/HackerRank 2023. 5. 15. 22:13
Problem Balanced Brackets | HackerRank Given a string containing three types of brackets, determine if it is balanced. www.hackerrank.com Solutions stack을 사용하는 대표적인 문제 유형이다. /* * Complete the 'isBalanced' function below. * * The function is expected to return a STRING. * The function accepts STRING s as parameter. */ string isBalanced(string s) { string result(""); stack st; map hash; hash['('] ..
-
[백준] 입력 속도 비교Coding Test/BaekJoon 2023. 5. 10. 12:26
백준에 올라와 있는 입력 속도 비교 글을 기억하기 위해 제 블로그에 옮겨 왔습니다. 출처는 아래 링크를 참고해주세요. 정수의 개수 N(=10,000,000), 둘째 줄부터 N개의 줄에 한 개의 자연수(10,000 이하)가 적힌 파일을 입력받는데 걸리는 시간을 측정. 10번 측정하여 평균값으로 순위를 매겼다고 합니다. 순위 언어 입력 방법 평균(초) 1 C11 mmap 0.043 2 C11 fread 0.0799 3 C11 getchar 0.3496 4 C++17 ios_base::sync_with_stdio(false); cin.tie(NULL); 0.5938 5 C++17 ios_base::sync_with_stdio(false); 0.6348 6 Java BufferedReader, Integer.p..
-
[프로그래머스] 기능개발 c++, javaCoding Test/programmers 2023. 5. 6. 12:22
문제 설명 프로그래머스 팀에서는 기능 개선 작업을 수행 중입니다. 각 기능은 진도가 100%일 때 서비스에 반영할 수 있습니다. 또, 각 기능의 개발속도는 모두 다르기 때문에 뒤에 있는 기능이 앞에 있는 기능보다 먼저 개발될 수 있고, 이때 뒤에 있는 기능은 앞에 있는 기능이 배포될 때 함께 배포됩니다. 먼저 배포되어야 하는 순서대로 작업의 진도가 적힌 정수 배열 progresses와 각 작업의 개발 속도가 적힌 정수 배열 speeds가 주어질 때 각 배포마다 몇 개의 기능이 배포되는지를 return 하도록 solution 함수를 완성하세요. 제한 사항 작업의 개수(progresses, speeds배열의 길이)는 100개 이하입니다. 작업 진도는 100 미만의 자연수입니다. 작업 속도는 100 이하의 자..
-
[프로그래머스] 캐시 c++Coding Test/programmers 2023. 5. 2. 09:54
문제 설명 지도개발팀에서 근무하는 제이지는 지도에서 도시 이름을 검색하면 해당 도시와 관련된 맛집 게시물들을 데이터베이스에서 읽어 보여주는 서비스를 개발하고 있다. 이 프로그램의 테스팅 업무를 담당하고 있는 어피치는 서비스를 오픈하기 전 각 로직에 대한 성능 측정을 수행하였는데, 제이지가 작성한 부분 중 데이터베이스에서 게시물을 가져오는 부분의 실행시간이 너무 오래 걸린다는 것을 알게 되었다. 어피치는 제이지에게 해당 로직을 개선하라고 닦달하기 시작하였고, 제이지는 DB 캐시를 적용하여 성능 개선을 시도하고 있지만 캐시 크기를 얼마로 해야 효율적인지 몰라 난감한 상황이다. 어피치에게 시달리는 제이지를 도와, DB 캐시를 적용할 때 캐시 크기에 따른 실행시간 측정 프로그램을 작성하시오. 제한 사항 캐시 교..