Good Morning bhaiya, Yesterday I got placed(on campus) in E2E networking on package around 12LPA. A huge thank to you, I am following you from last 8 month and your content and motivation help me a lot in my journey. Again Thank you soo much for your content and guidance. 💗❤
@codestorywithMIKАй бұрын
Many Many Congratulations 🎊🎊🎉🎉❤️❤️ So happy to hear this ❤️
@soumyajitpaul-p8zАй бұрын
Vhiya question kase Aya tha
@bashirahmad6668Ай бұрын
@@codestorywithMIK thank you so much sir 😊
@bashirahmad6668Ай бұрын
@@soumyajitpaul-p8z mostly resume base and project. DSA me linked list, graph and oops.
@aws_handlesАй бұрын
Congratulations
@Shubhammi1100Ай бұрын
Thanks, Mik. I solved this question in under 5 minutes by simply recalling the concept you explained in the robot collisions (2751) video.
@bhaskar_sainiАй бұрын
This channel taught me how to break down the question and think about what is required to solve the step. For eg in this question we require minimum element ...min heap rings in my mind, then for marking adjacent element I thought to take pair in min heap. All it takes 5 min to figure out the solution all thanks to MIk bhai. This is my approach class Solution { public: long long findScore(vector& nums) { long long sum = 0; //min heap priority_queuepq; int n = nums.size(); for(int i=0;i 0){ //add in sum sum += p.first; //mark adjacents make them negative if(p.second+1 < n){ nums[p.second+1] = -1; } if(p.second-1 >= 0){ nums[p.second-1] = -1; } } } return sum; } };
@codestorywithMIKАй бұрын
❤️❤️🙏🙏
@FanIQQuizАй бұрын
Done already. Here for motivation and learning
@kishorkale3905Ай бұрын
Approach is good and easy to understand
@DeadCode_DebugsАй бұрын
i only followed these 2 guys for dsa one is striver and this legend
@amarnathtripathy4350Ай бұрын
loved the first way literally GOATED
@gauravbanerjee2898Ай бұрын
Thanks a lot bhaiya ❤❤
@bhuppidhamiiАй бұрын
Coding after a long time, thanks mik
@kishorkale3905Ай бұрын
Nice explanation
@kishorkale3905Ай бұрын
Approach is good
@harshitgoyal7206Ай бұрын
attendance marking here 😀😇
@Tech_Explorer-d6gАй бұрын
Amazing!! eazzyyyyyyyyyyy hai.
@rajivkumarkaleАй бұрын
This can also be solved using monotonic stack, there is no need to keep the stack, we can simulate it using two pointers thus making Time complexity O(n) and space complexity O(1)
@kaushikdutta2666Ай бұрын
best content. :)
@Coder_Buzz07Ай бұрын
Motivation ❤❤
@GAURAVKUMAR-pc6bk27 күн бұрын
Hi MIK, i just finished this playlist of Heaps of yours. I just wanna say WOW. I loved it, the way you explained it is just amazing. Your channel is so so underrated. Hats off ! You gained another subscriber and a follower today
@codestorywithMIK26 күн бұрын
Thank you for your kind words ❤️❤️🙏🙏 Start from Graph Concepts first. Find the link and some details below. I usually create two playlists for every topic : 1) Concepts Playlist - Contains from basic concepts to expert concepts. 2) Popular Interview Problems playlist. I have created concepts and interview problems playlist for 1) Graph 2) Recursion 3) DP 4) Segment Tree Planning soon to create concepts playlist for Tree as well. Graph Concepts - kzbin.info/aero/PLpIkg8OmuX-LZB9jYzbbZchk277H5CbdY&si=lZG2IJTmSW4kRrx- Graph Popular Interview Problems - kzbin.info/aero/PLpIkg8OmuX-I_49pdy1XFY6OcATnxUrrO&si=CG2JvGWVmvoSqvWA Recursion Concepts - kzbin.info/aero/PLpIkg8OmuX-IBcXsfITH5ql0Lqci1MYPM&si=614iI4NyHY-FTeJH Recursion Problems (In progress) - kzbin.info/aero/PLpIkg8OmuX-IXOgDP_YYiJFqfCFKFBDkO&si=88fBhRnr62OYTnDP DP Concepts (In progress) - kzbin.info/aero/PLpIkg8OmuX-JhFpkhgrAwZRtukO0SkwAt&si=laFVYy6ep2BkOg0s DP Popular interview problems - kzbin.info/aero/PLpIkg8OmuX-L_QqcKB5abYynQbonaNcq3&si=VHEn9b-wqTnAVyyi Segment Tree Concepts - kzbin.info/aero/PLpIkg8OmuX-K1qUIQToCllUO0UIKXt8dB&si=xm7DqRN4H0eZwna4
@GAURAVKUMAR-pc6bk26 күн бұрын
@codestorywithMIK Thank you it's such a great help, gotta complete this all 😊❤️
@user-du6et6ek4nАй бұрын
Thanks bhaiya , generally i won't use set data struct that much but through your videos and appraoch i learned new technique and find multiple answer for a single problem 🍁🍁🎖🎖 Here is my appraoch using priority queue and unordered_set class Solution { public: #define ll long long #define p pair long long findScore(vector& nums) { ll sum = 0; priority_queue< p , vector , greater > pq; unordered_set st; for(int i=0; i 0 && index < nums.size()-1){ st.insert(index -1); st.insert(index +1); } else if(index == 0) st.insert(index + 1); else st.insert(index -1); } } return sum; } };
@GovindSinghGurjar-kj8ejАй бұрын
class Solution { public: long long findScore(vector& nums) { stack st; long long ans=0; for(int i=0;i
@vishwashsoni610Ай бұрын
Sir, this is how I solved this question. I know it's not the most optimal solution, but I tried it on my own. class Solution { public: long long findScore(vector& nums) { unordered_mapmp; int n = nums.size(); for(int i=0;i= 0){ marked[idx-1] = true; } if(idx+1 < n){ marked[idx+1] = true; } } return ans; } };
@codestorywithMIKАй бұрын
Thank you for sharing your solution! Glad to know you tried and came up with a different approach. 👌
@NikunjKumarGuptaАй бұрын
instead you continue at marked[idx] == true condition , you can break ;
@vishwashsoni610Ай бұрын
@@NikunjKumarGupta no we can not use break; continue ensures that the current iteration is skipped, but the loop keeps running to process the next element in the priority queue.
@NikunjKumarGuptaАй бұрын
@@vishwashsoni610 hm I just noticed , thanks 👍
@Tech_Explorer-d6gАй бұрын
Hi Mazhar, I’d be grateful if you could make a playlist about computer fundamentals. If that's not possible right now, maybe you could make a short video on the resources you found most useful while learning. There are tons of resources out there, in PDFs and long videos, and it confuses me how much I should know. I understand the importance of having thorough knowledge, but given my time constraints, I want to use my time wisely. One question that puzzles me is how much I should study. I wasn't really a serious student before, but I'm trying now, and it feels overwhelming at times, especially with DSA, development, computer fundamentals, and aptitude. Your videos have been really helpful with DSA, and I am truly grateful for that. I hope you can come up with something for the other topics as well. Thanks!
@RishabhChatterjee-fg2gzАй бұрын
bhaiya pehle mene map and heap se banaya tha class Solution { public: long long findScore(vector& nums) { long score = 0; unordered_map mp; priority_queue pq; for(int i = 0; i < nums.size(); i++) { mp[i] = nums[i]; pq.push({nums[i], i}); } while(!pq.empty()) { long smallestElement = pq.top().first; long index = pq.top().second; pq.pop(); if(mp.find(index) != mp.end()) { score += smallestElement; mp.erase(index); if(index - 1 >= 0) mp.erase(index - 1); if(index + 1 < nums.size()) mp.erase(index + 1); } } return score; } }; uske baad map ko nhi use karke sirf ek visited array use kar liya class Solution { public: long long findScore(vector& nums) { long score = 0; vector visited(nums.size()); priority_queue pq; for(int i = 0; i < nums.size(); i++) pq.push({nums[i], i}); while(!pq.empty()) { long smallestElement = pq.top().first; long index = pq.top().second; pq.pop(); if(!visited[index]) { score += smallestElement; visited[index] = true; if(index - 1 >= 0) visited[index -1] = true; if(index + 1 < nums.size()) visited[index + 1] = true; } } return score; } };
@yashagarwal9784Ай бұрын
Hi Mazhar, I saw an order of N solution also using deque data structure, If you could explain that approach too. Also, You are the best!!! I have been folloowing you since day 1 on of your YT
@soumyajitpaul-p8zАй бұрын
Vhiya ek algorithms ka playlists banado
@NihitGupta-dw4pbАй бұрын
Can you plz explain the stack approach ??
@pun3eth_Ай бұрын
Bhayya,Can you explain the deque solution for above problem
@joydeep-halderАй бұрын
@helloliuhbnnАй бұрын
Hi sir make structure course i will join
@codestorywithMIKАй бұрын
Hi there, Appreciate your kind suggestion! I'll keep it in mind and explore the possibility ❤️❤️🙏🙏
@jeevan-23Ай бұрын
hi mik i have now confidence in all topics and I'm in final year and i have a question, what should i do like how should i make myself even stronger , like where should i practice the questions. can you help me please
@vaibhavshahi5601Ай бұрын
Can you make a video on leetcode 30?
@HeetVichhivoraАй бұрын
mai "SHOONYA" hu
@aizad786iqbalАй бұрын
one doubt, you said heapify takes taken O(n), but if we insert via for loop and push, takes O(n log n), would be good to know how exactly...
@codestorywithMIKАй бұрын
A very good Question. Thanks for asking ❤️ Heapify (O(n)): When we build a heap using the heapify process, we start from the bottom-most non-leaf nodes and move upwards. Each level has fewer nodes, and the cost of heapifying decreases as we move up. The total time complexity sums up to O(n) - I will create a video on why is this so. Insert via for loop and push (O(n log n)): If we insert elements one by one into the heap using a loop, each insertion takes O(log n) time (to maintain the heap property). For n elements, this results in O(n log n) complexity. So, the difference lies in the approach: Heapify is a bulk operation that optimizes the process. Push works element by element, which is less efficient for building a heap from scratch.
@zaffarzeshan1308Ай бұрын
same ele min index how to choose?
@shreyabajaj4588Ай бұрын
class Solution { public long findScore(int[] nums) { int []arr=new int [nums.length]; Arrays.fill(arr,0); PriorityQueuepq=new PriorityQueue((a,b)->{ if(a[0]!=b[0]){ return Integer.compare(a[0],b[0]); }else{ return Integer.compare(a[1],b[1]); } }); long ans=0; int count=0; for(int i=0;i
@100solarmassАй бұрын
class Solution public long findScore(int[] nums) { int n nums.length; long sum = 0; var idx = new Integer[n]; for (int i = 0; i < n; i++) idx[i] = i; Arrays.sort(idx, (a,b) nums[a]-nums[b]); var visited new boolean[n + 2]; for (int i: idx) { if (!visited[i+1]) { sum += nums[i]; visited[i] = true; visited[i + 2] = true; } } return sum Some solved like this🥶🥶🥶
@aizad786iqbalАй бұрын
this question is marked with topic greedy, bit manipulation etc, not sure if that is possible... it is marked with a lot of topics on leetcode...
@codestorywithMIKАй бұрын
I have a feeling that they mentioned bitset because it can be used here to mark the visited numbers instead of using a visited vector or hashset etc. But i don’t think it’s even required. We can ignore it .
@YogeshBora07Ай бұрын
bhaiya please upload a video onn leetcode 3259
@aizad786iqbalАй бұрын
easy tha but nahi ban paa raha, I didn't think of visited array for some reason, bas map/set aa raha tha dimag mai... btw PriorityQueue pq = new PriorityQueue((x, y) -> x[0] == y[0] ? Integer.compare(x[1],y[1]) : Integer.compare(x[0],y[0])); this is easier to understand in java...
public long findScore(int[]nums){ long score; for(int i=0;i
@rajeshkumar-ws5kuАй бұрын
this is the brute force of this questions class Solution { public: pair smallestNumber(vector &nums){ int n=nums.size(); int ind=-1; int min=1e9; for(int i=0;inums[i]){ min=nums[i]; ind=i; } } return { min,ind}; } long long findScore(vector& nums) { /// brutr force int n=nums.size(); long long score=0; while (true) { auto [small, ind] = smallestNumber(nums); if (small == 1e9) break; // Exit when no valid numbers are left score += small; nums[ind] = 1e9; // Mark the current number as processed // Mark neighbors as processed if (ind > 0) nums[ind - 1] = 1e9; if (ind < nums.size() - 1) nums[ind + 1] = 1e9; } return score; } };
@100solarmassАй бұрын
PriorityQueue pq = new PriorityQueue(); for (int x: nums) pq.add(x); for (int j = 0; j < n; j++) { int min = pq.poll(); for (int i = 0; i < n; i++) { if (nums [i] min && nums[i] > 0) { sum += nums[i]; nums[i] = -nums [i]; if (n>1) { if (i = 0) { nums[i + 1] = -Math.abs(nums[i + 1]); else if (i = n - 1) { nums[i - 1] = -Math.abs(nums[i - 1]); } else { nums[i - 1] = -Math.abs(nums[i - 1]); nums [i + 1] = Math.abs(nums [i + 1]); } } return sum; 5 test were failed due to TLE