# CategoryHackerRank

## HackerRank âCamelCaseâ Solution

H

Short Problem Definition: Alice wrote a sequence of words in CamelCase as a string of letters, , having the following properties: It is a concatenation of one or more words consisting of English letters. All letters in the first word are lowercase. For each of the subsequent words, the first letter is uppercase and rest of the letters are lowercase...

## HackerRank âA Very Big Sumâ Solution

H

Short Problem Definition:
Calculate and print the sum of the elements in an array, keeping in mind that some of those integers may be quite large.
A Very Big Sum
Complexity:
time complexity is O(N)
space complexity is O(1)
Execution:
Just add all of this together. No magic.
Solution:

## HackerRank âCastle on the Gridâ Solution

H

Short Problem Definition: You are given a grid with both sides equal to N/N. Rows and columns are numbered from 0/0 to Nâ1/Nâ1. There is a castle on the intersection of the aath row and the bbth column. Your task is to calculate the minimum number of steps it would take to move the castle from its initial position to the goal position (c/d). It is guaranteed that it is possible to reach the goal...

## HackerRank âAbsolute Permutationâ Solution

H

Short Problem Definition: We define P to be a permutation of the first n natural numbers in the range [1,n]. Let pos[i] denote the value at position i in permutation P using 1-based indexing. P is considered to be an absolute permutation if |pos[i]-i| = K holds true for every i. Â Link Absolute Permutation Complexity: time complexity is O(N) space complexity is O(N) Execution: The time complexity...

## HackerRank âCats And A Mouseâ Solution

H

Short Problem Definition: Two cats and a mouse are at various positions on a line. You will be given their starting positions. Your task is to determine which cat will reach the mouse first, assuming the mouse doesnât move and the cats travel at equal speed. If the cats arrive at the same time, the mouse will be allowed to move and it will escape while they fight. Link Cats And A Mouse...

## HackerRank âAlmost Sortedâ Solution

H

Short Problem Definition: Given an array of integers, determine whether the array can be sorted inÂ ascending orderÂ using only one of the following operations one time. Swap two elements. Reverse one sub-segment. Determine whether one, both or neither of the operations will complete the task. If both work, chooseÂ swap. For instance, given an array [2, 3, 5, 4] either swap the 4 and 5; or reverse...

## HackerRank âCavity Mapâ Solution

H

Short Problem Definition: You are given a square map of size nĂn. Each cell of the map has a value denoting its depth. We will call a cell of the map a cavity if and only if this cell is not on the border of the map and each cell adjacent to it has strictly smaller depth. Two cells are adjacent if they have a common side. Link Cavity Map Complexity: time complexity is O(N^2) space complexity is...

## HackerRank âAlternating Charactersâ Solution

H

Short Problem Definition: Shashank likes strings in which consecutive characters are different. For example, he likes ABABA, while he doesnât like ABAA. Given a string containing characters A and B only, he wants to change it into a string he likes. To do this, he is allowed to delete the characters in the string. Your task is to find the minimum number of required deletions. Link...