Latest stories

Project Euler Problem 1: Multiples of 3 and 5 Solution


Problem Statement (see If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. Solutions HackerRank see  My code solves 5 out of 5 test cases (score: 100%) Difficulty 5% Project Euler ranks this problem at 5% (out of 100%). Hackerrank...

HackerRank ‘Super Reduced String’ Solution


Short Problem Definition: Steve has a string of lowercase characters in range ascii[‘a’..’z’]. He wants to reduce the string to its shortest length by doing a series of operations. In each operation he selects a pair of adjacent lowercase letters that match, and he deletes them. For instance, the string aab could be shortened to b in one operation. Steve’s task is to...

HackerRank ‘The Time In Words’ Solution


Short Problem Definition: Given the time in numerals we may convert it into words. Link The Time In Words Complexity: time complexity is O(?) space complexity is O(?) Execution: I might have hinted at my opinion in the past: Why do “challenges” like this even exist? It requires 0 brain power, but you will spend an hour figuring out the fine details of English and fixing bugs. Solution: 1 2 3 4 5...

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...

HackerRank ‘Strange Counter’ Solution


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 ‘Strong Password’ Solution


Short Problem Definition: Louise joined a social networking site to stay in touch with her friends. The signup page required her to input a name and a password. However, the password must be strong. The website considers a password to be strong if it satisfies the following criteria: Its length is at least 6. It contains at least one digit. It contains at least one...

HackerRank ‘Taum and B’day’ Solution


Short Problem Definition: Taum is planning to celebrate the birthday of his friend Diksha. There are two types of gifts that Diksha wants from Taum: one is black and the other is white. To make her happy, Taum has to buy B number of black gifts and W number of white gifts. Link Taum and B’day Complexity: time complexity is O(1) space complexity is O(1) Execution: The cost for each present is...

HackerRank ‘String Construction’ Solution


Short Problem Definition: Amanda has a string of lowercase letters that she wants to copy to a new string. She can perform the following operations with the given costs. She can perform them any number of times to construct a new string p: Append a character to the end of string p at a cost of 1 dollar. Choose any substring of p and append it to the end of  at...

HackerRank ‘The Grid Search’ Solution


Short Problem Definition: Given a 2D array of digits, try to find the location of a given 2D pattern of digits Link The Grid Search Complexity: time complexity is O(n^2 * m^2) space complexity is O(1) Execution: There are many sophisticated 2d pattern matching algorithms out there. Just think of computer vision, robotics, gaming… The issue with most of them is, that they are rather heuristics...

HackerRank ‘The Power Sum’ Solution


Short Problem Definition: Find the number of ways that a given integer, X , can be expressed as the sum of the Nth powers of unique, natural numbers. For example, if X = 13 and N = 2, we have to find all combinations of unique squares adding up to 13. The only solution is 2^2 + 3^2. Link The Power Sum Complexity: time complexity is O(N!) space complexity is O(1) Execution: This solution does not...


About Me

I like to Code and Love to share the codes.