Coding Test
-
[프로그래머스] 폰켓몬 c++Coding Test/programmers 2022. 8. 1. 16:20
문제 설명 제한 사항 nums는 폰켓몬의 종류 번호가 담긴 1차원 배열입니다. nums의 길이(N)는 1 이상 10,000 이하의 자연수이며, 항상 짝수로 주어집니다. 폰켓몬의 종류 번호는 1 이상 200,000 이하의 자연수로 나타냅니다. 가장 많은 종류의 폰켓몬을 선택하는 방법이 여러 가지인 경우에도, 선택할 수 있는 폰켓몬 종류 개수의 최댓값 하나만 return 하면 됩니다. 입출력 예 nums result [3,1,2,3] 2 [3,3,3,2,2,4] 3 [3,3,3,2,2,2] 2 문제 풀이 N마리의 폰켓몬 중 N/2를 가질 수 있다. 중복을 허용하지 않는 map을 사용해서 폰켓몬의 종류를 카운트한다. map의 크기가 폰켓몬 종류 개수가 된다. #include #include using name..
-
[HackerRank] Tower Breakers c++Coding Test/HackerRank 2022. 7. 20. 19:20
Problem Two players are playing a game of Tower Breakers! Player 1 always moves first, and both players always play optimally.The rules of the game are as follows: Initially there are n towers. Each tower is of height m. The players move in alternating turns. In each turn, a player can choose a tower of height x and reduce its height to y, where 1
-
[HackerRank] Zig Zag Sequence C++Coding Test/HackerRank 2022. 7. 20. 14:54
Problem In this challenge, the task is to debug the existing code to successfully execute all provided test files. Given an array of N distinct integers, transform the array into a zig zag sequence by permuting the array elements. A sequence will be called a zig zag sequence if the first K elements in the sequence are in increasing order and the last K elements are in decreasing order, where k =..
-
[HackerRank] counting sort 1 c++Coding Test/HackerRank 2022. 7. 20. 10:29
Problem Quicksort usually has a running time of n x log(n), but is there an algorithm that can sort even faster? In general, this is not possible. Most sorting algorithms are comparison sorts, i.e. they sort a list just by comparing the elements to one another. A comparison sort algorithm cannot beat n x log(n) (worst-case) running time, since n x log(n) represents the minimum number of comparis..
-
[HackerRank] Between Two Sets c++Coding Test/HackerRank 2022. 7. 19. 23:18
Problem There will be two arrays of integers. Determine all integers that satisfy the following two conditions: The elements of the first array are all factors of the integer being considered The integer being considered is a factor of all elements of the second array These numbers are referred to as being between the two arrays. Determine how many such numbers exist. Example a = [2, 6] b = [24,..