solved on my own, only possible because i am following you regularly from last 3 months.🙏
@indrajitpal025 ай бұрын
Today's problem was very much easy when you figure it out
@AryanVats6035 ай бұрын
Did it myself today!! Sir!
@thesoftwareguy21835 ай бұрын
Thanks for the hint, Sir!! Have a Good Day a head!!!
@aws_handles5 ай бұрын
you are one of the best tutors no doubt. I have shared your channel to almost everyone I know in coding groups
@abhishekrao84445 ай бұрын
we also be use int ones = accumulate(begin(nums), end(nums), 0); or int ones = count(begin(nums), end(nums), 1);
@yashkalia23115 ай бұрын
As our placement interview are approaching,can you create a video on time and space complexity of ds and major algos
@manasdeora46015 ай бұрын
best question for interview
@prakharsinha41455 ай бұрын
trust me, you're awesome!
@ganeshjaggineni40975 ай бұрын
NICE SUPER EXCELLENT MOTIVATED
@SuryaCharanV5 ай бұрын
thx for the effort good explanation.
@naveentmyug5 ай бұрын
great explanation, thanks
@anmolbansal40095 ай бұрын
sir can u make one video for each data structure on time complexity and space complexity where like for graphs u can tell and little explain time complexities of main things like dfs,bfs,dijikstra and other importat questions Please can u make 1 such video of time complexities and space complexities for each data structure.....i m facing a lot of difficulty in time complexities
@yashkalia23115 ай бұрын
Yesssss
@aws_handles5 ай бұрын
yes please mik
@Mlrit-fg9eo5 ай бұрын
keep making detailed explaination videos
@gauravbanerjee28985 ай бұрын
Thanks a lot bhaiya ❤❤
@YashMalav-kh1ov5 ай бұрын
Sir can you mentions those ques in pinned comment which are simiar to this problem
@RohitKumar-dz8dh5 ай бұрын
Thanks 😊
@ashwint9595 ай бұрын
class Solution { public int minSwaps(int[] nums) { int numOfOnes = 0; for (int x : nums) { if (x == 1) numOfOnes += 1; } int numOfZeroes = 0; int min = Integer.MAX_VALUE; int start = 0; for (int end = 0; end < 2 *nums.length; end++) { if (nums[end % nums.length] == 0) { numOfZeroes++; } while (end - start + 1 == numOfOnes) { min = Math.min(numOfZeroes, min); if (nums[start % nums.length] == 0) numOfZeroes--; start++; } } return numOfOnes == 0 ? 0 : min; } } You can do it by counting zeroes as well in the sliding window.. The major trick in this problem is to figure size of the window since K is not given. Here it will be equal to number of ones in the window. Once that is figured out, it is a very easy problem..
@mikasaackerman14015 ай бұрын
After a long break 🙂❤
@KinjalGupta-ts2cz5 ай бұрын
5 mins into the video and I coded it myself without using extra space☺. My approach is slightly different: class Solution { public: int minSwaps(vector& nums) { int n=nums.size(); int cntOnes=0; for(int i=0;i
@sauravchandra105 ай бұрын
This was easy, but after I saw which topic it belonged to.
@aashutoshsathe80785 ай бұрын
thank you sirrr
@doomhead91095 ай бұрын
size of array can be 10^5 for this problem if we make 0 to 2 * 10^5 travel then it should not pass the all test cases as we can run 10^9 operations in 1 sec. Can you explain like why this is not a problem for us ?
@SaurabhKumar-oz2rh5 ай бұрын
❤❤
@aizad786iqbal5 ай бұрын
even though I know very little of sliding window was able to code it myself after your explations... with both of the approaches... class Solution { public int minSwaps(int[] nums) { int n = nums.length; //int[] arr = new int[2*n]; int totalOnes = 0; for(int i=0;i
@RishabhChatterjee-fg2gz5 ай бұрын
mik bhai, is tarike question mein kyese figure out karunga, ki ye sliding window ka problem hai, kiyuki sliding window ki pattern hota hai, find subarray of length k, etc... but is question mein kyese karunga, sliding window ka aur patterns discuss koro bhai
@VijaySolanki-jk6wm5 ай бұрын
more practice will let u know all things bro !!
@aws_handles5 ай бұрын
practice practice practice. I had solved a similar problem and hence was able to figure out sliding window
@zebra-er6xc5 ай бұрын
@@aws_handles can you share some similar problems like this one
@RishabhChatterjee-fg2gz5 ай бұрын
@@aws_handles Yes, I know practice is only way but I want to know, more types of patterns which are solved using sliding window, like find k length subarray, etc... can you say?
@imPriyansh775 ай бұрын
@@zebra-er6xc see problems under leetcode 'similar problems' section in description page
@AsK-kh4ze5 ай бұрын
please also provide code in java.
@izanahmad57055 ай бұрын
Here is My solution: int minSwaps(vector &nums) { int n = nums.size(); int totalOnes = count(nums.begin(), nums.end(), 1); int currOnes = count(nums.begin(), nums.begin() + totalOnes, 1); int minSwap = totalOnes - currOnes; int i = 0, j = totalOnes - 1; while (j < 2 * n - 1) { j++; if (nums[j % n]) { currOnes++; } if (nums[i % n]) { currOnes--; } i++; minSwap = min(minSwap, totalOnes - currOnes); } return minSwap; }
@rohanprabhakar19915 ай бұрын
I have been doing Daily leetcode for around 250 days but now i don't want to do it. i am not getting any motivation to do it and it leads to losing my consistency. I am loosing the patience i just want to see solution now and also after 5 min i don't want to watch and skip it to direct solution. What can i do i don't want to think by myself as it's not pushing me anymore,i want your opinion now. Help me
@closer96895 ай бұрын
I am also in kind of same situation.Don't know why, But i could not solve new problems with enthusiasm. Inspite of knowing that i am not that good enough untill now, I am not feeling to put efforts while solving, and i become impatient while solving problem.
@yogeshwargupta58785 ай бұрын
you should try to upload video of gfg ptod also
@harishms53303 ай бұрын
U should try to solve it on your own also
@kumkumslab58115 ай бұрын
int one=0; for(auto &i:nums)if(i==1)one++; int i=0; int j=one-1; int cnt=0; for(int k=i;k
@dayashankarlakhotia49435 ай бұрын
public int minSwaps(int[]nums){ int cntOnes=0; for(int i=0;i=cntOnes-1) min=Math.min(min,cntOnes-sum); } for(int i=0;i
@Rajdweep5 ай бұрын
yr sliding window ka intuition hi nhi aya...main soch rha tha largest group ko nikalke fir sides ko increase kru...aisa intuition kaise banau itne din hogye fir bhi nhi aya
@zebra-er6xc5 ай бұрын
mai bhi largest ones ka group nikal kar try kar raha tha, video dekh ke sliding window ka idea aaya
@ashwint9595 ай бұрын
IS anyone having problems running leetcode solutions due to the slowness of the site?
@dayashankarlakhotia49435 ай бұрын
we can implement it in our windowSize how many min zero. public int minSwaps(int[]nums){ int windowSize=0; for(int num:nums) windowSize+=num; int curZeros=0; for(int i=0;i
@BHONEPIYUSH5 ай бұрын
Haath beth gaya hai dsa sikhane pe , not many youtubers are like this
@deeptidip98645 ай бұрын
Please topic ka approach phle mention mat kiya karo😢 we come here to get overview and poora approach phle pata chal jata🤧
@codestorywithMIK5 ай бұрын
I tried to hide the approach in the beginning. I will try to increase the duration of initial part for hiding the topic name. Thank you 🙏😇