Search Your Question...!

The Hurdle Race | Python Solution | HackerRank

 A video player plays a game in which the character competes in a hurdle race. Hurdles are of varying heights, and the characters have a maximum height they can jump. There is a magic potion they can take that will increase their maximum jump height by  unit for each dose. How many doses of the potion must the character take to be able to jump all of the hurdles. If the character can already clear all of the hurdles, return .

Example

The character can jump  unit high initially and must take  doses of potion to be able to jump all of the hurdles.

Function Description

Complete the hurdleRace function in the editor below.

hurdleRace has the following parameter(s):

  • int k: the height the character can jump naturally
  • int height[n]: the heights of each hurdle

Climbing the Leaderboard | Python Solution | HackerRank

 An arcade game player wants to climb to the top of the leaderboard and track their ranking. The game uses Dense Ranking, so its leaderboard works like this:

  • The player with the highest score is ranked number  on the leaderboard.
  • Players who have equal scores receive the same ranking number, and the next player(s) receive the immediately following ranking number.

Example


The ranked players will have ranks , and , respectively. If the player's scores are  and , their rankings after each game are  and . Return .

Picking Numbers | Python Solution | HackerRank

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.

Cats and a Mouse | Python Solution | HackerRank

 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 does not 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.

You are given  queries in the form of , and  representing the respective positions for cats  and , and for mouse . Complete the function  to return the appropriate answer to each query, which will be printed on a new line.

  • If cat  catches the mouse first, print Cat A.
  • If cat  catches the mouse first, print Cat B.
  • If both cats reach the mouse at the same time, print Mouse C as the two cats fight and mouse escapes.