Short Problem Definition: Bob has a strange counter. At the first second, it displays the number 3. Each second, the number displayed by the counter decrements by 1 until it reaches 1. The counter counts down in cycles. In next second, the timer resets to 2x the initial number for the prior cycle and continues counting down. Link Strange Counter Complexity: time complexity is O(log(N)) space...

## HackerRank ‘The Love-Letter Mystery’ Solution

Short Problem Definition: James found a love letter his friend Harry has written for his girlfriend. James is a prankster, so he decides to meddle with the letter. He changes all the words in the letter into palindromes. Link The Love-Letter Mystery Complexity: time complexity is O(N*T); space complexity is O(1) Execution: You process the string from the beginning towards mid and always decrement...

## HackerRank ‘Max Min’ / ‘Angry Children’ Solution

Short Problem Definition: Given a list of N integers, your task is to select K integers from the list such that its unfairness is minimized. Link Max Min Complexity: time complexity is O(N*log(N)); space complexity is O(N) Execution: The unfairness is the distance between K elements in a sorted array. Solution: 1 2 3 4 5 6 7 8 9 10 11 12 13 #!/usr/bin/py if __name__ == '__main__':...

## HackerRank ‘Game of Thrones – I’ Solution

Short Problem Definition: Dothraki are planning an attack to usurp King Robert from his kingdom. King Robert learns of this conspiracy from Raven and plans to lock the single door through which an enemy can enter his kingdom. But, to lock the door he needs a key that is an anagram of a certain palindrome string. Link Game of Thrones – I Complexity: time complexity is O(N); space complexity...

## HackerRank ‘Chocolate Feast’ Solution

Short Problem Definition: Little Bob loves chocolates, and goes to a store with $N in his pocket. The price of each chocolate is $C. The store offers a discount: for every M wrappers he gives to the store, he gets one chocolate for free. How many chocolates does Bob get to eat? Link Chocolate Feast Complexity: time complexity is O(N); space complexity is O(1) Execution: Evaluate the number of...

## HackerRank ‘Filling Jars’ Solution

Short Problem Definition: Animesh has N empty candy jars, numbered from 1 to N, with infinite capacity. He performs M operations. Each operation is described by 3 integers a, b and k. Here, a and b are indices of the jars, and k is the number of candies to be added inside each jar whose index lies betweena and b (both inclusive). Can you tell the average number of candies after M operations? Link...

## HackerRank ‘ACM ICPC Team’ Solution

Short Problem Definition: You are given a list of N people who are attending ACM-ICPC World Finals. Each of them are either well versed in a topic or they are not. Find out the maximum number of topics a 2-person team can know. And also find out how many teams can know that maximum number of topics. Link ACM ICPC Team Complexity: time complexity is O(N^3); space complexity is O(N) Execution: I...