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

Опубликовано: 25 Июль 2020
на канале: 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  


Смотрите видео Max Min Java Coding Challenge | HackerRank | How'd You Code That? онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Ed Clark 25 Июль 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 1,560 раз и оно понравилось 59 людям.