Bhaiya please it's a request from my side, never stop teaching .... you are a true gem in teaching
@codestorywithMIK Жыл бұрын
Means a lot to me 😇🙏❤️ Sure thing
@DeepakSingh-fd2ix Жыл бұрын
very true bro
@aws_handles Жыл бұрын
True
@wearevacationuncoverers Жыл бұрын
0:09 This always boosts my confidence.
@deepakdass4710 Жыл бұрын
Sir, ONE REQUEST from my side I have been following your channel since last 2 months. I just love your teaching style, you have helped me a lot in making my problem solving skills better. I am about to start following your GRAPH playlist after my exams end. I have one request for you. Please try to make videos for LEETCODE contests as well, if possible, I think that will help us to learn devloping intuition in contest.
@codestorywithMIK Жыл бұрын
Yes sure thing. I have slowly started it. As of now, i am able to take out time for one problem (last Qn of contest or any which is required most in the comments - most Qn 3 and Qn 4) Soon with time, I will try covering all contest problems 🙏❤️ Thank you so much for watching my contents 😇🙏
@deepakdass4710 Жыл бұрын
@@codestorywithMIK Yes Q3 and 4 will be fine for now. Thanks sir 😍😍😍😍
@akan3shaD Жыл бұрын
@@codestorywithMIK yess sir please make intuition videos on LC contest as well 🔥
@DeepakSingh-fd2ix Жыл бұрын
yes @codestorywithmik please sir post the contest solution also because no one can explain the question easy as you explain
@dchennaraidu Жыл бұрын
Bhai, legend ho app! 🙏🏼 Appreciate your skills and patience to break it down and explain clearly!
@codestorywithMIK Жыл бұрын
It means a lot 🙏🙏❤️❤️
@ammanchhetri6716 Жыл бұрын
tags - Adobe
@codestorywithMIK Жыл бұрын
Thank you so much 😇❤️🙏
@ammanchhetri6716 Жыл бұрын
@@codestorywithMIK anytime 🤝
@thor1626 Жыл бұрын
Solved the question by my own after looking at the test cases, but watching your video made me understand the underlying logic. My java sol : (3 ms Beats 99.36% of users with Java.) class Solution { public int[] getSumAbsoluteDifferences(int[] nums) { int len = nums.length; int[] prefixSum = new int[len + 1]; prefixSum[0] = 0; int sum = 0; int index = 1; for (int i = 0; i < len; i++) { sum += nums[i]; prefixSum[index] = sum; index++; } for (int i = 0; i < len; i++) { int x = (prefixSum[len] - prefixSum[i]) - (nums[i] * (len - i)); int y = (nums[i] * i) - prefixSum[i]; nums[i] = x + y; } return nums; } }
@Ramneet04 Жыл бұрын
I got the intuition that we have to make and imade two arrays prefix and suffix sum array but unable to get the formula.Glad I came up till this solution,I even solved yesterday's ,say before yesterday question by own,thx a lot, even did with 0(1) space solution.
@FanIQQuiz Жыл бұрын
Done. It was easy as compared to usual Weekends problems. Thanks a lot for your explanation
@BiswajitDas-lk7pp10 ай бұрын
Amazing Explanation Bro ❤
@codeandtalk6 Жыл бұрын
Absolute makes problem hard 😢 but bro explained like ❤❤❤❤
@de_coder1 Жыл бұрын
Was able to do it by approach 1, calculating prefix sum on the way was good.
@sauravchandra10 Жыл бұрын
Seemed like an easy one, and like always your way of thinking is so clear and your explanations so simple. My implementation: class Solution { public: vector getSumAbsoluteDifferences(vector& nums) { int n=nums.size(), pre=0; vector preSum(n,0); for(int i=0;i=0;i--){ int leftSum = (pre-preSum[i]) - (nums[i]*(n-1-i)); int rightSum= 0; if(i>0) rightSum += (nums[i]*i)-preSum[i-1]; preSum[i]=leftSum+rightSum; } return preSum; } };
@saurabhKumar-hj6yp Жыл бұрын
You are really an awesome person.
@aws_handles Жыл бұрын
You are just fabulous 🔥
@nirmaljaat9029 Жыл бұрын
Very Easy to Understand class Solution { public: vector getSumAbsoluteDifferences(vector& nums) { int sum=0; for(int & i: nums){ sum+=i; } int n=nums.size(); vector ans; int l=nums[0]; ans.push_back(sum-nums[0]*n); sum-=nums[0]; for(int i=1;i
@dhairyachauhan6622 Жыл бұрын
Took me like 40 mins to think of the solution but happy to tell that i did it on my own :) my solution :- class Solution { public: typedef long long ll; vector getSumAbsoluteDifferences(vector& nums) { int n = nums.size(); vectorprefix(n,0); vectorsuffix(n,0); int sum = 0; for(int i = 0;i=0;j--){ sum += nums[j]; suffix[j] = sum - (n-j)*nums[j]; } vectorans(n,0); for(int i =0 ;i N , -VE, -VE 3-> +VE ,N,-VE 5-> +VE,+VE,N THE ABSOLUTE VALUE OF 2 AND 5 WERE CORRECT BUT NOT FOR 3 REASON BEING THERE WAS ONE +VE AND ONE -VE, EITHER USE ALL +VE OR ALL -VE. SO I THOUGH SINCE IT WAS SORTED ALL THE VALUES TILL AND BEFORE THE CURRENT NO. WILL ALWAYS BE POSITIVE SO I STORED (CURRENT NO. * LENGTH - SUM TILL THE LENGTH IN THE ARRAY) [prefix[i] = (i+1)*nums[i] - sum;] EG: [2,3,5] IN THE SUFFIX ARRAY AS (suffix[j] = sum - (n-j)*nums[j];) NOW BOTH WILL BE POSITIVE AND I WILL GET MY ANSWER. YES I COULD HAVE USED ONLY ONE PREFIX ARRAY BUT IT IS MORE UNDERSTANDABLE IN 2 ARRAYS.
@codestorywithMIK Жыл бұрын
Awesome 🔥💪❤️
@dhairyachauhan6622 Жыл бұрын
@@codestorywithMIK
@infinitygaming7192 Жыл бұрын
class Solution: def getSumAbsoluteDifferences(self, nums: List[int]) -> List[int]: prefix_sum = [nums[0]] for i in range(1,len(nums)): prefix_sum.append(nums[i] + prefix_sum[i-1]) arr = [] for i in range(len(nums)): left = ((nums[i]*(i+1) )-prefix_sum[i]) right = (nums[i]*(len(nums) - (i+1))) - (prefix_sum[-1] - prefix_sum[i]) term = abs(left) + abs(right) arr.append(term) return arr
@55_hetpatel74 Жыл бұрын
Nice
@DeepakSingh-fd2ix Жыл бұрын
Sir, this biweekly contest question about finding the minimum number of coins for fruits seems quite tricky and interesting. If you could explain it, it would help me a lot
@codestorywithMIK Жыл бұрын
Can you please share the qn link
@ashishj94973 ай бұрын
legend
@DevOpskagyaan Жыл бұрын
Legend 🫡❤️
@souravjoshi2293 Жыл бұрын
Made it super easy.
@crazyduniya128 Жыл бұрын
how you get confidence to directly submit your code, without running on example test cases
@codestorywithMIK Жыл бұрын
Hi there, actually before making video I submit my code as well in the GitHub and hence i sometimes submit directly. But i usually suggest everyone to first submit on example test cases and then after that submit.
@nk-fs8bj Жыл бұрын
❤❤❤
@biswarupacharjya2258 Жыл бұрын
Sir if possible linklist playlist 🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@infinitygaming7192 Жыл бұрын
solved this question without any hints
@codestorywithMIK Жыл бұрын
Awesome 😇😇🙌
@factsmotivation7728 Жыл бұрын
Anyone can say me how can i join whatapp group,i am unable to join whatapp group, help...
@codestorywithMIK Жыл бұрын
Can you please try from this link - whatsapp.com/channel/0029Va6kVSjICVfiVdsHgi1A
@factsmotivation7728 Жыл бұрын
@@codestorywithMIK thank you Bhaiya
@shivam9048 Жыл бұрын
🥰👍
@dayashankarlakhotia4943 Жыл бұрын
public int getSumAbsoluteDifferences (int[]nums){ int n=nums.length; int[]ans=new int [n];int[]prefix =new int [n]; int[]suffix =new int [n]; prefix[0]=nums[0]; for(int i=1;i=0;i--){ suffix [i]=suffix [i+1]+nums[i]; for(int i=0;i