# Tag Archives: Hackerrank

## Find the sum of even Fibonacci numbers.

Question: Find the sum of even fibonacci numbers upto a limit N. Input:100 Output: 44 Fibonacci numbers are a miracle of Math and are defined as:- f(0) = 0 f(1) = 1 f(n) = f(n-1) + f(n-2); for n>=2 Thus the Fibonacci series can be given as 0, 1, 1, 2, 3, 5, 8, 13, 21… Let us… Read More »

## Determine if two strings share a common sub-string.

Question: Given two strings, determine if they share a common sub-string. If they have a common sub-string, print YES else print NO. Input: studyalgorithms algos Output: YES This is one of the easy problems but can get a little tricky, if we do not understand it completely. Let us try to understand the test case String 1 =… Read More »

## [Hackerrank] – Multiples of 3 and 5

Question: 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 ‘N’ Input: N = 100 Output: 2318 The most naive approach to solve this problem… Read More »

## [Hackerrank] – Palindrome Index

Question: Given a string, identify the index of character to be removed to change the string into a palindrome. If the string cannot be converted to palindrome or is already a palindrome just return -1. Input: abckdeedcba Output: 3 (0 based indexing) To start off with the problem, we must first understand that there can be two possible… Read More »

## [Hackerrank] – Weighted Uniform Strings

Let us try to simplify the problem as much as we can. We are given with some of the terms. Weights:- According to the problem each character in the English alphabet has been assigned a weight. ‘a’ has been given a weight of 1, ‘b’ has a weight of 2, and so on. The weight of ‘z’ is… Read More »

## Pangrams

Question: Given a string, identify if it is a pangram. Input: The quick brown fox jumps over the lazy little dog. Output: pangram To start with the problem statement we must first understand what is a pangram. A pangram is a string that contains all the characters in the English alphabet at-least once. This means that the string… Read More »

## [Hackerrank] – Two Characters

A string is said to be valid when it has only distinct characters and none of them repeat simultaneously. For example, if string ‘s two distinct characters are x and y, then valid examples could be xyxyx or yxyxy but not xxyy or xyyx. Question: Given a sample string, we need to determine what is the maximum length… Read More »

## [Hackerrank] – Camel Case

Question: Given a camelCase string, find the number of words in the string. Input: saveChangesInTheEditor Output: 5 Camel case is a very popular style of naming variables and methods in most of the programming languages. Not only it helps to make the code readable but also ensures that the variable names are unique and easy to remember. A… Read More »