title-img


Plus Minus

Given an array of integers, calculate the ratios of its elements that are positive, negative, and zero. Print the decimal value of each fraction on a new line with 6 places after the decimal. Note: This challenge introduces precision problems. The test cases are scaled to six decimal places, though answers with absolute error of up to 10^ -4 are acceptable. Example : arr = [1,1,0, -1,-1] There are n =5 elements, two positive, two negative and one zero. Their ratios are 2/5=0.400000 , 2

View Solution →

Staircase

Staircase detail: This is a staircase of size n = 4: # ## ### #### Its base and height are both equal to n. It 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. staircase has the following parameter(s): int n: an integer Print: Print a staircase as described above. Input Format:

View Solution →

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. arr = [1,3,5,7,9] Example The minimum sum is 1 + 3 + 5 + 7 = 16 and the maximum sum is 3 + 5 + 7 + 9 = 24. the function prints 16 24 . Function Description Complete the miniMaxSum function in the editor below. miniMaxSum has the following

View Solution →

Birthday Cake Candles

You are in charge of the cake for a child's birthday. You have decided the cake will have one candle for each year of their total age. They will only be able to blow out the tallest of the candles. Count how many candles are tallest. Example candles = [4,4,1,3] The maximum height candles are 4 units high. There are of 2 them, so return 2. Function Description Complete the function birthdayCakeCandles in the editor below. birthdayCakeCandles has the following parameter(s):

View Solution →

Time Conversion

Given a time in 12 -hour AM/PM format, convert it to military (24-hour) time. Note: - 12:00:00AM on a 12-hour clock is 00:00:00 on a 24-hour clock. - 12:00:00PM on a 12-hour clock is 12:00:00 on a 24-hour clock. Example s = '12 : 01: 00PM' Return '12:01:00'. s = '12 : 01: 00AM' Return '00:01:00'. Function Description Complete the timeConversion function in the editor below. It should return a new string representing the input time in 24 hour format. timeConversion h

View Solution →