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”

# Author Archives: Robin Hedwig

## Python Program to draw Infinity Symbol|Using Turtle

from turtle import *bgcolor(“white”)color(“red”)speed(11)right(45)for i in range(150):circle(30)if 7<i<62:left(5)if 80<i<133:right(5)if i<80:forward(10)else:forward(5)

## Python Program to draw colour rings|Using Turtle

import turtlecolors=[‘orange’,’red’,’pink’,’yellow’,’blue’,’green’]screen=turtle.Screen()trtl=turtle.Turtle()trtl.speed(0)screen.bgcolor(“black”) for x in range(120): trtl.pencolor(colors[x%6]) trtl.width(x/5+1) trtl.forward(x) trtl.left(20)

## Minimum Swaps 2| HACKERRANK| PYPY 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”

## Blog

Staircase HackerRank Problem solution-Using Python Staircase detail This is a staircase of size : Its base and height are both equal to . It is drawn using # symbols and spaces. The last line is not preceded by any spaces. Write a program that prints a staircase of size . Function Description Complete the staircase function in the editor below. staircase has theContinue reading “Blog”