# CategoryHackerRank

## HackerRank ‘Mini-Max Sum’ Solution

H

Short Problem Definition: 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. Link Mini-Max Sum Complexity: time complexity is O(N) space complexity is O(1) Execution: Rather than recalculating the sum every...

## HackerRank ‘Minimum Time Required’ Solution

H

Short Problem Definition: You are planning production for an order. You have a number of machines that each have a fixed number of days to produce an item. Given that all the machines operate simultaneously, determine the minimum number of days to produce the required order. Link Minimum Time Required Complexity: time complexity is O(N*log(10*9)) space complexity is O(1) Execution: This problem...

## HackerRank ‘Missing Numbers’ Solution

H

Short Problem Definition: Numeros, the Artist, had two lists A and B, such that B was a permutation of A. Numeros was very proud of these lists. Unfortunately, while transporting them from one exhibition to another, some numbers from A got left out. Can you find the numbers missing? Link Sherlock and Array Complexity: time complexity is O(n) space complexity is O(n) Execution: The problem...

## HackerRank ‘Largest Rectangle’ Solution

H

Short Problem Definition: There are NN buildings in a certain two-dimensional landscape. Each building has a height given by hi,i∈[1,N]hi,i∈[1,N]. If you join KK adjacent buildings, they will form a solid rectangle of area K×min(hi,hi+1,…,hi+k−1)K×min(hi,hi+1,…,hi+k−1). Given NN buildings, find the greatest such solid area formed by consecutive buildings. Link Largest Rectangle Complexity: time...

## HackerRank ‘New Year Chaos’ Solution

H

Short Problem Definition: It’s New Year’s Day and everyone’s in line for the Wonderland rollercoaster ride! There are a number of people queued up, and each person wears a sticker indicating their initial position in the queue. Initial positions increment by 1 from 1 at the front of the line to N at the back. Any person in the queue can bribe the person directly in front of them to...

## HackerRank ‘Left Rotation’ Solution

H

Short Problem Definition: A left rotation operation on an array shifts each of the array’s elements 1 unit to the left. For example, if 2 left rotations are performed on array [1,2,3,4,5], then the array would become [3,4,5,1,2]. Link Arrays: Left Rotation Complexity: time complexity is O(N) space complexity is O(N) Execution: Solutions like this is where python really shines. Simple and...

## HackerRank ‘Non-Divisible Subset’ Solution

H

Short Problem Definition: Given a set S of n distinct integers, print the size of a maximal subset S’ of S where the sum of any 2 numbers in S’ are not evenly divisible by k. Link Non-Divisible Subset Complexity: time complexity is O(N) space complexity is O(N) Execution: This is by all means not an easy task and is also reflected by the high failure ratio of the participants. For a sum...

## HackerRank ‘Library Fine’ Solution

H

Short Problem Definition: The Head Librarian at a library wants you to make a program that calculates the fine for returning the book after the return date. You are given the actual and the expected return dates Link Library Fine Complexity: time complexity is O(?) space complexity is O(?) Execution: HackerRank does not support the dateutil library. This should have been computed in terms of date...

## HackerRank ‘Number List’ Solution

H

Short Problem Definition: Shashank loves to play with arrays a lot. Today, he has an array A consisting of N positive integers. At first, Shashank listed all the subarrays of his array A on a paper and later replaced all the subarrays on the paper with the maximum element present in the respective subarray. Link Number List Complexity: time complexity is O(N) space complexity is O(1) Execution:...

## HackerRank ‘Lily’s Homework’ Solution

H

Short Problem Definition: Whenever George asks Lily to hang out, she’s busy doing homework. George wants to help her finish it faster, but he’s in over his head! Can you help George understand Lily’s homework so she can hang out with him? Consider an array of m distinct integers, arr = [a, a, …, a[n-1]]. George can swap any two elements of the array any number of times. An array...