CategoryHackerRank

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 ‘Gemstones’ Solution

H

Short Problem Definition: John has discovered various rocks. Each rock is composed of various elements, and each element is represented by a lower-case Latin letter from ‘a’ to ‘z’. An element can be present multiple times in a rock. An element is called a gem-element if it occurs at least once in each of the rocks. Given the list of N rocks with their compositions, display the number of gem...

HackerRank ‘Grading Students’ Solution

H

Short Problem Definition: 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. Link Grading Students Complexity: time complexity is O(N) space complexity is O(N) Execution: Follow the problem specification. The solution could be further optimized to...

HackerRank ‘HackerRank Bear and Steady Gene’ Solution

H

Short Problem Definition: A gene is represented as a string of length N (where  is divisible by 4), composed of the letters A, C, G, and T. It is considered to be steady if each of the four letters occurs exactly 1/4 times. For example, GACT and AAGGCCTT are both steady genes. Link Bear and Steady Gene Complexity: time complexity is O(N) space complexity is...

HackerRank ‘Halloween Party’ Solution

H

Short Problem Definition: Alex is attending a Halloween party with his girlfriend Silvia. At the party, Silvia spots the corner of an infinite chocolate bar.If the chocolate can be served as only 1 x 1 sized pieces and Alex can cut the chocolate bar exactly K times, what is the maximum number of chocolate pieces Alex can cut and give Silvia? Link Halloween Party Complexity: time complexity is...

HackerRank ‘Halloween Sale’ Solution

H

Short Problem Definition: You wish to buy video games from the famous online video game store Mist. Usually, all games are sold at the same price, p dollars. However, they are planning to have the seasonal Halloween Sale next month in which you can buy games at a cheaper price. Specifically, the first game you buy during the sale will be sold at dollars, but every subsequent game you buy...

HackerRank ‘Handshake’ Solution

H

Short Problem Definition: At the annual meeting of Board of Directors of Acme Inc, every one starts shaking hands with everyone else in the room. Given the fact that any two persons shake hand exactly once, Can you tell the total count of handshakes? Link Handshake Complexity: time complexity is O(n) space complexity is O(n) Execution: I love this problem as it is a great reference for other pair...

HackerRank ‘Happy Ladybugs’ Solution

H

Short Problem Definition: Happy Ladybugs is a board game having the following properties: A ladybug is happy only when it’s left or right adjacent cell (i.e., ) b[i+/-1] is occupied by another ladybug having the same color. Link Happy Ladybugs Complexity: time complexity is O(N) space complexity is O(1) Execution: This challenge definition does not require a full sort. It only wants to know...

Archives

Categories