Daily Leetcode Challenge | NOV 14 | Minimized Maximum of Products Distributed to Any Store
Вставка
- Опубліковано 18 лис 2024
- Daily Leetcode Challenge- November 2024 - Day 14 - Minimized Maximum of Products Distributed to Any Store
Approach/Topic : Greedy
question link: leetcode.com/p...
optimized approach beats 90% of the test cases
Like, share and subscribe
***********************
Hi, I am a SDE , at one of the Fortune 50 companies!!
The intent of this channel is to motivate the community to code everyday, and also to make their coding rounds-during interview, a bit easier !! :)
Every question has a 1)brute-force approach 2)optimized approach, and the language used is simple English
I try my best to keep my solutions beginner friendly and simple to understand.
thanks for your support!! :)
***********************
Leetcode Today Challenge,
Daily Coding Practise,
Leetcode 100 days of code,
Python Daily Coding Challenge,
Daily LeetCoding Challenge ,
daily leetcode challenge,
daily leetcode questions,
daily leetcode problem,
leetcode daily today,
leetcode daily problem today,
leetcode daily challenge,
leetcode daily practise,
leetcode solutions,
letcode python,
leetcode hard problems,
leetcode easy problems,
leetcode medium problems,
leetcode for begineers,
leetcode python problems,
leetcode python,
leetcode python solutions,
leetcode python hard,
leetcode python medium,
leetcode python easy,
leetcode python english,
leetcode python solutions in english
Where to learn dp
where to learn graphs
where to learn dsa
how to start programming
how to start coding
where to learn trees
what is memoisation
what is tabulation
what are graphs
where to learn Operating systems
where to learn dbms
where to learn oops
where to learn computer networks
where to learn low level design
where to learn cs fundamentalS
Gate smashers
Placement guide
How to start programming
where to learn cpp
where to learn python
where to learn javascript
where to learn java
Placement guide
languages to learn
resources to learn data structures
Projects development
Software developer engineer ,
Importance of side projects ,
How to become a machine learning engineer ,
Associate engineer
Data structures Algorithms
College Life, College, Memories
Where to learn dp
where to learn graphs
where to learn dsa
how to start programming
how to start coding
where to learn trees
what is memoization
what is tabulation
what are graphs
where to learn programming
how to start coding
where to learn coding
where to learn DSA
resources to learn programming
how to crack amazon
how to crack placement
what is blockchain
blockchain technology explained
blockchain technology in hindi
web development roadmap
android development roadmap
MERN stack roadmap
roadmap for 2nd years
roadmap for opensource
roadmap for ios development
roadmap to learn DSA
microsoft internship,
microsoft intern 2022,
microsoft internship India,
microsoft internship experience
microsoft,software engineer
#leetcode #leet_preparation_tips #leetcodesolution #coding #interview
#CodingInterview #NovemberLeetCodingChallenge #Google #Amazon #programming #march #codinglife #meta #faang #maang
Hindi Explanation here: ua-cam.com/video/MzMSfD6vhTU/v-deo.html
import heapq
class Solution:
def minimizedMaximum(self, n: int, quantities: List[int]) -> int:
m=len(quantities)
minHeap=[]
for i in quantities: # O(m)
minHeap.append((-i,i,1)) # avg quantity per store , total quantity,#no of stores
heapq.heapify(minHeap) # O(m)
print(minHeap)
print('n-m =',n-m)
#O((n-m)logm)
for i in range(n-m): #O(n-m)
_,totalQuantity,totalStores=heapq.heappop(minHeap) #O(logm)
totalStores+=1
avg=(totalQuantity/totalStores)
heapq.heappush(minHeap,(-avg,totalQuantity,totalStores)) #O(logm)
print(minHeap)
avg,_,_=heapq.heappop(minHeap)
avg=avg*(-1)
return ceil(avg)