09 - Mini Max Sum | Warmup | Hackerrank Solution | Python

preview_player
Показать описание
⭐️ Content Description ⭐️
In this video, I have explained on how to solve mini max sum using a single for loop in python. This hackerrank problem is a part of Problem Solving | Practice | Algorithms | Warmup | Mini Max Sum and solved in python. The complexity of this solution is O (n).

Make a small donation to support the channel 🙏🙏🙏:-

#minimaxsum #howtosolve #hackerrank #hackerranksolutions #hackersrealm #python #warmup #problemsolving #tutorial #algorithms #datastructures #programming #coding #codinginterview #education #aswin
Рекомендации по теме
Комментарии
Автор

def miniMaxSum(arr):
# Write your code here
list1 = []
for i in range(len(arr)):

print(min(list1), max(list1))

shubhambajirao
Автор

Once could u explain me the last print statement and why did we take such a big number for initialization in minnum variable

sreyassistla
Автор

I had a different approach. Sorting the array in ascending order, the taking the sum of first 4 integers to get minisum and last 4 to get maxsum ? Am I missing out on any edge cases ?

nitinmadan
Автор

We can first use the sorting then we can take the sum by considering first four to minimum and the from the last number to four elements

ananthakumararulanantham
Автор

How can we customize inputs like in hackerrank problem? we add "arr = [1, 3, 5, 7, 9]" before "n = len (arr)"?

ClaudiuB
Автор

How total sum - min value anf total sum - max value gives largest and min sum of 4 selected value?, is it a math concept of permutations?

laxus
Автор

please explain why did you take minimum = you told in previous comment that result is higher than 0 i didnt understand it pleas can you explain it

saiakhileshm
Автор

please explain this problem in c++.. I am unable to figure out.

lakshitagupta
Автор

bro do you have a discord server? like is there any way we can contact you?

srikarchatla
Автор

Minnum=min(minnum, arr[I]) can you explain this line

amittripathi
Автор

for i in range(n):
sum += arr [i]
Minimum=min(arr)
Maximum=max(arr)
Print(sum-maximum, sum-minimum)
Brother can we write the code like this..i.e., by calculating minimum and maximum values of the entire array and then subtracting them from the final sum??

nbvxskl
Автор

def miniMaxSum(arr):
# Write your code here
mnarr = arr.copy()
mnarr.remove(max(arr))
arr.remove(min(arr))

print(sum(mnarr), sum(arr))

Is this optimal solution than what is explained in this video ?

vickyeee