(see projecteuler.net/problem=2) Each new term in the Fibonacci sequence is generated by adding the previous two terms.By starting with 1 and 2, the first 10 terms will be:1, 2, 3, 5, 8, 13, 21, 34, 55, 89, …By considering the terms in the Fibonacci sequence whose values do not exceed four million,find the sum of the even-valued terms. My Algorithm As explained in the problem statement, you...

## Project Euler Problem 1: Multiples of 3 and 5 Solution

Problem Statement (seeÂ projecteuler.net/problem=1) 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 âWeighted Uniform Stringsâ Solution

Short Problem Definition: A weighted string is a string of lowercase English letters where each letter has a weight. Character weights are 1 to 26 from a to zâŚ Link Weighted Uniform String Complexity: time complexity is O(N) space complexity is O(N) Execution: Parsing the string for every query is suboptimal, so I first preprocess the string. Now we know that uniform...

## HackerRank âWaiterâ Solution

Short Problem Definition: You are a waiter at a party. There are NN stacked plates. Each plate has a number written on it. You start picking up the plates from the top one by one and check whether the number written on the plate is divisible by a primeâŚ. Link Waiter Complexity: time complexity isÂ O(N*Q) space complexity is O(N) Execution: First of all, generate primes using Sieve, or copy-paste a...

## HackerRank âUtopian Treeâ Solution

Short Problem Definition: The Utopian Tree goes through 2 cycles of growth every year. The first growth cycle occurs during the spring, when it doubles in height. The second growth cycle occurs during the summer, when its height increases by 1 meter. Â Now, a new Utopian Tree sapling is planted at the onset of spring. Its height is 1 meter. Can you find the height of the tree after N growth cycles...

## HackerRank âTwo Stringsâ Solution

Short Problem Definition:

You are given two strings, A and B. Find if there is a substring that appears in both A and B.

Link

Two Strings

Complexity:

time complexity is O(N+M);

space complexity is O(1)

Execution:

At first sight this seems like a longest common substring problem. It is actually much easier. You just need to find out if there are two equal letters in both strings A and B.

Solution:

## HackerRank âTime Conversionâ Solution

Short Problem Definition: You are given time in AM/PM format. Convert this into a 24 hour format. Link Time Â Conversion Complexity: time complexity is O(?) space complexity is O(?) Execution: Transforming date formats without the use of the proper libraries is a disaster waiting to happen. Date formats are ever changing and a waste of engineering effort. Just use whatever package comes with your...

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

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

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