Given an array of integers, find the longest subarray where the absolute difference between any two elements is less than or equal to . Example There are two subarrays meeting the criterion:  and . The maximum length subarray has  elements. Function Description Complete the pickingNumbers function in the editor below. pickingNumbers has the following parameter(s): int a[n]: an array of integers ReturnsContinue reading “PICKING NUMBERS| PYTHON PROGRAMMING | HACKERRANK SOLUTION”


You are given an unordered array consisting of consecutive integers  [1, 2, 3, …, n] without any duplicates. You are allowed to swap any two elements. Find the minimum number of swaps required to sort the array in ascending order. Example Perform the following steps: It took  swaps to sort the array. Function Description Complete the function minimumSwaps inContinue reading “Minimum Swaps 2| HACKERRANK| PYPY SOLUTION”

Repeated String | HackerRank Solution | Python Programming| Solution

There is a string, , of lowercase English letters that is repeated infinitely many times. Given an integer, , find and print the number of letter a‘s in the first  letters of the infinite string. Example The substring we consider is , the first  characters of the infinite string. There are  occurrences of a in the substring. Function Description Complete the repeatedString function in the editorContinue reading “Repeated String | HackerRank Solution | Python Programming| Solution”

Jumping-on-the-clouds | Solution | hackerRank | Python

There is a new mobile game that starts with consecutively numbered clouds. Some of the clouds are thunderheads and others are cumulus. The player can jump on any cumulus cloud having a number that is equal to the number of the current cloud plus  or . The player must avoid the thunderheads. Determine the minimum number ofContinue reading “Jumping-on-the-clouds | Solution | hackerRank | Python”

Between Two Sets | HackerRank | Solution | Python Programming

There will be two arrays of integers. Determine all integers that satisfy the following two conditions: The elements of the first array are all factors of the integer being considered The integer being considered is a factor of all elements of the second array These numbers are referred to as being between the two arrays. Determine howContinue reading “Between Two Sets | HackerRank | Solution | Python Programming”