Coding Test/HackerRank
-
[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['('] ..
-
[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,..
-
[HackerRank] Number Line Jumps c++Coding Test/HackerRank 2022. 7. 19. 15:49
Problem You are choreographing a circus show with various animals. For one act, you are given two kangaroos on a number line ready to jump in the positive direction (i.e, toward positive infinity). The first kangaroo starts at location x1 and moves at a rate of v1 meters per jump. The second kangaroo starts at location x2 and moves at a rate of v2 meters per jump. You have to figure out a way to..