Tag Archives: Hackerrank

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] – 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 »


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 »