HackerRank Interview Prep: Max Min - Greedy Algorithm Solution

Опубликовано: 01 September 2026
на канале: Brian Dyck
1,876
33

Hello, my name is Brian Dyck, I am a full-time software engineer and a Computer Science graduate walking through HackerRank problems for new and old programmers alike. My goal is to help programmers build up skills and not just see the solutions to problems, but to learn how to think through the problems. Many new videos to come, so stay tuned!

You will be given a list of integers, , and a single integer . You must create an array of length from elements of such that its unfairness is minimized. Call that array . Unfairness of an array is calculated as

Where:
max denotes the largest integer in
min denotes the smallest integer in