본문 바로가기

문제풀이

[HackerRank]Apple and Orange 문제 Sam's house has an apple tree and an orange tree that yield an abundance of fruit. In the diagram below, the red region denotes his house, where s is the start point, and t is the endpoint. The apple tree is to the left of his house, and the orange tree is to its right. You can assume the trees are located on a single point, where the apple tree is at point a, and the orange tree is at point ..
[HackerRank]Grading Students 문제 HackerLand University has the following grading policy: Every student receives a grade in the inclusive range from 0 to 100. Any grade less than 40 is a failing grade. Sam is a professor at the university and likes to round each student's grade according to these rules: If the difference between the grade and the next multiple of 5 is less than 3, round grade up to the next multiple of 5. If ..
[HackerRank]Time Conversion Time Conversion Given a time in 12-hour AM/PM format, convert it to military (24-hour) time. Note: Midnight is 12:00:00AM on a 12-hour clock, and 00:00:00 on a 24-hour clock. Noon is 12:00:00PM on a 12-hour clock, and 12:00:00 on a 24-hour clock. Function Description Complete the timeConversion function in the editor below. It should return a new string representing the input time in 24 hour for..
[HackerRank]Birthday Cake Candles You are in charge of the cake for your niece's birthday and have decided the cake will have one candle for each year of her total age. When she blows out the candles, she’ll only be able to blow out the tallest ones. Your task is to find out how many candles she can successfully blow out. Function Description Complete the function birthdayCakeCandles in the editor below. It must return an intege..
[HackerRank]Mini-Max Sum 문제 Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers. For example, arr = [1, 3, 5, 7, 9]. Our minimum sum is 1+3+5+7=16 and our maximum sum is 3+5+7+9=24. We would print 16 24. Function Description Complete..
[HackerRank]Staircase 문제 Observe that its base and height are both equal to n, and the image is drawn using # symbols and spaces. The last line is not preceded by any spaces. Write a program that prints a staircase of size n. Function Description Complete the staircase function in the editor below. It should print a staircase as described above. Input Format A single integer, n, denoting the size of the staircase. Ou..
[HackerRank]Plus Minus 문제 Given an array of integers, calculate the fractions of its elements that are positive, negative, and are zeros. Print the decimal value of each fraction on a new line. Function Description Complete the plusMinus function in the editor below. It should print out the ratio of positive, negative and zero items in the array, each on a separate line rounded to six decimals. Input Format The first ..
[HackerRank]Diagonal Difference 문제 Given a square matrix, calculate the absolute difference between the sums of its diagonals. Function description Complete the diagonal Difference function in the editor below. It must return an integer representing the absolute diagonal difference. Input Format The first line contains a single integer, , the number of rows and columns in the matrix . Each of the next lines describes a row, , ..