Minimize the Heights II | Array | Sorting | GFG POTD | C++ | Java | Code Kar Lo

preview_player
Показать описание
Given an array arr[] denoting heights of N towers and a positive integer K.

For each tower, you must perform exactly one of the following operations exactly once.

Increase the height of the tower by K
Decrease the height of the tower by K
Find out the minimum possible difference between the height of the shortest and tallest towers after you have modified each tower.

0:00 Introduction
0:10 Problem Statement
0:57 Explanation
10:15 C++ Code
13:56 Java Code

gfg potd
gfg potd today
gfg problem of the day
potd gfg
potd
potd today
gfg

#dsa #datastructures #algorithm #gfg #potd #coding #array #strings #tree #binarysearchtree #codekarlo #dynamicprogramming
Рекомендации по теме
Комментарии
Автор

bro i-1 ko small consider kr rhe phir usme + hone chahiye.. aur i me - hone chahiye kyuki wo greater hai.. to phir 5:40 par ulta kyu kr diya?? confuse ho gye kya?

RelaxHERE-zkts
Автор

ye mn and mx kyunn nahi consider kar rahe hai ham log while taking min and max, usually toh wahi likhte hai, default values ko chaneg karke..

ye har baar arr[0]+k, and arr[n-1] - k se kyun compare kar rahe hai ?

aizadiqbal