I manage to complete this one by myself using the most optimal approach thanks to you for all the confidence. If possible can you also make a video about the Hard version of this question i think that will help lot of people thanks.
This Legend woke up at I don’t know when, posted a video at 5 AM and now posted another video of today’s POTD 😭😭😭 Mai bhi mehnat karunga yaar itni. I want this level of dedication 😭😭
same sir aaj ka motivation mere liye perfect he kyoki aaaj he mene dekhi kuch logo ki profile or jealous feel huva ki unhone itni jalde sab kar liya hn or abhe mne tu start he kiya hn or second year mn bhe hun bahot late hun esa feel ho rha tha 😅
Python approach using heapify (Beats 100% Py submissions): class Solution: def getFinalState(self, nums: List[int], k: int, multiplier: int) -> List[int]: pq = [(nums[ind], ind) for ind in range(len(nums))] heapq.heapify(pq) for _ in range(k): el, ind = heappop(pq) nums[ind] = el*multiplier heappush(pq, (nums[ind], ind)) return nums
but when elements are rearranged in push_heap( ), it will be entered at the last index of the array right ? and then accordingly it will get sort but this should take O(logn) right ? the internal working of the heapify tree remains same here, so the over all sloution stil remains n*logn, isn't it ? because what would be the possibility that the new number formed will always be less then all the elements ( in case if you are wondering that push_heap() just adds the new element in the starting of the array resulting in same heap that heapify will give-- which is i think not the case )
Thanks for the analysis! A bit off-topic, but I wanted to ask: My OKX wallet holds some USDT, and I have the seed phrase. (alarm fetch churn bridge exercise tape speak race clerk couch crater letter). How can I transfer them to Binance?
sir this how i solved this question : class Solution { public: typedef pair P; vector getFinalState(vector& nums, int k, int multiplier) { int n = nums.size(); priority_queue pq; for(int i=0;i
Brute Force Approach :
class Solution {
private:
void min(vector &nums , int multiplier) {
int mini = nums[0];
int j = 0;
for(int i = 1; i < nums.size(); i++) {
if(nums[i] < mini) {
mini = nums[i];
j = i;
}
}
nums[j] = mini*multiplier;
}
public:
vector getFinalState(vector& nums, int k, int multiplier) {
while(k--) {
min(nums,multiplier);
}
return nums;
}
};
I manage to complete this one by myself using the most optimal approach thanks to you for all the confidence. If possible can you also make a video about the Hard version of this question i think that will help lot of people thanks.
Tum heap se hi banaye kya?
@ yes with Heap and with Set from C++ STL
I have completed this by myself using min heap. Still watching your video for learning from your thought process.
Same pinch
Me too ☝️
Same here ✋
Solved the problem easily using priority queue. But still you don't fail to provide new concepts. Hats off Bhaiya 🔥 Didn't know about this make_heap
This Legend woke up at I don’t know when, posted a video at 5 AM and now posted another video of today’s POTD 😭😭😭
Mai bhi mehnat karunga yaar itni. I want this level of dedication 😭😭
You github repo is pure gold, thankyouuu and thankyouuuuuuuuuuuuuuuuuuuuu
can you share the link please ?
Brute Approach
class Solution {
public:
pair small(vector& nums)
{
int n=nums.size();
int smoll=nums[0];
int pos=0;
for(int i=1;i nums[i])
{
smoll=nums[i];
pos=i;
}
}
return {smoll,pos};
}
vector getFinalState(vector& nums, int k, int multiplier) {
while(k--)
{
pair pos=small(nums);
nums[pos.second]=pos.first * multiplier;
}
return nums;
}
};
same sir aaj ka motivation mere liye perfect he kyoki aaaj he mene dekhi kuch logo ki profile or jealous feel huva ki unhone itni jalde sab kar liya hn or abhe mne tu start he kiya hn or second year mn bhe hun bahot late hun esa feel ho rha tha 😅
I did it myself thanks it was easy today
Pehle Heap, Graph, sliding window jaise topics se dar lagta tha. But not now. Thanks to you MIK ❤
Kabhi kabhi lagta hai mai cpp ka pura syntax bhi nhi janta mujhe aaj ye pta chla bhaiya 😢
Python approach using heapify (Beats 100% Py submissions):
class Solution:
def getFinalState(self, nums: List[int], k: int, multiplier: int) -> List[int]:
pq = [(nums[ind], ind) for ind in range(len(nums))]
heapq.heapify(pq)
for _ in range(k):
el, ind = heappop(pq)
nums[ind] = el*multiplier
heappush(pq, (nums[ind], ind))
return nums
he is not scared of consistency , consistency is scared of him
Bhaiya logic ban gaya tha sirf syntax error aagayi...tysm mik bhaiya❤
but when elements are rearranged in push_heap( ), it will be entered at the last index of the array right ? and then accordingly it will get sort but this should take O(logn) right ? the internal working of the heapify tree remains same here, so the over all sloution stil remains n*logn, isn't it ? because what would be the possibility that the new number formed will always be less then all the elements ( in case if you are wondering that push_heap() just adds the new element in the starting of the array resulting in same heap that heapify will give-- which is i think not the case )
First 🎉❤
Thank you so much for resuming DP Concepts. Waiting for next video .
Done today's POTD easily.
Learnt about heapify today...
That's why i always watch your vedio even though i managed to solve this problem on my own
❤❤❤
Iska part 2 kyese hoga bhaiya, kya observation hai wo video banao bhaiya
Leetcode 3266
Can you please solve the 3266 the second version of this problem
Thanks for the analysis! A bit off-topic, but I wanted to ask: My OKX wallet holds some USDT, and I have the seed phrase. (alarm fetch churn bridge exercise tape speak race clerk couch crater letter). How can I transfer them to Binance?
Please do something for LEETCODE contest also 🙏🙏🙏
plz make video on the its 2nd part for large inputs
Please also solve in java
Please make yesterday's leetcode contest question 3 video. It was very hard
sir this how i solved this question :
class Solution {
public:
typedef pair P;
vector getFinalState(vector& nums, int k, int multiplier) {
int n = nums.size();
priority_queue pq;
for(int i=0;i
same solution
Same
But while(--k){
for(i to n)// to find min value of array each time
this is better as its k*n
}
bhai dsa course launch kar do
Bhaiya video ki slides ki pdf bhi upload Kar diya kariya
Added the link in the video description above ❤️🙏
please solution of yesterday contest of leetcode. hard and medium question please @codestorywithmik