## Day of the Programmer – HackerRank Solution

Problem : Marie invented a Time Machine and wants to test it by time-traveling to visit Russia on the Day of the Programmer (the 256th day of the year) during a year in the inclusive range from 1700 to 2700. From 1700 to 1917, Russia’s official calendar was the Julian

## Migratory Birds – HackerRank Solution

Problem : You have been asked to help study the population of birds migrating across the continent. Each type of bird you are interested in will be identified by an integer value. Each time a particular kind of bird is spotted, its id number will be added to your array of

## Divisible Sum Pairs – HackerRank Solution

Problem : You are given an array of n integers, ar = [ar[0], ar[1], ..., ar[n-1]], and a positive integer, k. Find and print the number of (i, j) pairs where i < j and ar[i] + ar[j] is divisible by k. For example, ar = [1, 2, 3, 4, 5, 6] and k = 5. Our three pairs meeting

## Birthday Chocolate – HackerRank Solution

Problem : Lily has a chocolate bar that she wants to share it with Ron for his birthday. Each of the squares has an integer on it. She decides to share a contiguous segment of the bar selected such that the length of the segment matches Ron’s birth month and the sum of

## Breaking the Records – HackerRank Solutions

Problem : Maria plays college basketball and wants to go pro. Each season she maintains a record of her play. She tabulates the number of times she breaks her season record for most points and least points in a game. Points scored in the first game

## Between Two Sets – HackerRank Solution

Problem : You will be given two arrays of integers and asked to 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

## Kangaroo – HackerRank Solution

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

## Apple and Orange – HackerRank Solution

Problem : 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

## Grading Students – HackerRank Solution

Problem : HackerLand University has the following grading policy: Every student receives a grade in the inclusive range from 1 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

## Time Conversion – HackerRank Solution

Problem : 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

## Birthday Cake Candles – HackerRank Solution

Problem : 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

## Mini-Max Sum – HackerRank Solution

Problem : 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. Example : arr = [1, 3,

## Staircase – HackerRank Solution

Problem : Consider a staircase of size n = 4: 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

## Plus Minus – HackerRank Solution

Problem : 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

## Diagonal Difference – HackerRank Solution

Problem : Given a square matrix, calculate the absolute difference between the sums of its diagonals. For example, the square matrix arr is shown below: The left-to-right diagonal = 1 + 5 + 9 = 15. The right to left diagonal = 3 + 5 + 9 = 15. Their

## A Very Big Sum -HackerRank Solution

Problem : In this challenge, you are required to calculate and print the sum of the elements in an array, keeping in mind that some of those integers may be quite large. Function Description : Complete the aVeryBigSum function in the editor below. It must return

## Compare the Triplets – HackerRank Solution

Problem : Alice and Bob each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a scale from 1 to 100 for three categories: problem clarity, originality, and difficulty. The rating for Alice’s