Max Min Java Coding Challenge | HackerRank | How'd You Code That?

Published: 25 July 2020
on channel: Ed Clark
1,560
59

Today, we’re solving the HackerRank challenge, Max Min.

The problem statement reads:
You will be given a list of integers as an integer array, “a-r-r”, and a single integer, “k”. You must create an array of length, “k”, from the elements in the integer array, such that unfairness is minimized. We’ll call that array, “suba-r-r”. Unfairness of an array is calculated as follows:

The maximum value, or the largest integer in the subarray subtracted by the minimum value, or the smallest integer in the subarray.

As an example, consider the array [1-4-7, and 2], and k equals 2. Picking the values 4 and 7, with the maximum value being 7, and the minimum value being 4: unfairness = 3. Testing for all pairs: the solution [1 and 2], provides the minimum unfairness.

Closed Captions/Subtitles - [email protected]

Video Editing - [email protected]

Song: All Night - Ikson (Vlog No Copyright Music)
Music promoted by Vlog No Copyright Music.
  / ikson  


Watch video Max Min Java Coding Challenge | HackerRank | How'd You Code That? online without registration, duration hours minute second in high quality. This video was added by user Ed Clark 25 July 2020, don't forget to share it with your friends and acquaintances, it has been viewed on our site 1,560 once and liked it 59 people.