Move all the negative elements to one side of the array | Arrays | Love Babbar DSA Sheet | Hindi
Vložit
- čas přidán 20. 08. 2024
- Please like, share and subscribe if you found the video useful. Feel free to ask in comments section if you have any doubts. :)
#DataStructuresAndAlgorithms
#LoveBabbarDSASheet
#interviewpreparation
Move all the negative elements to one side of the array solution
Move all the negative elements to one side of the array Leetcode
Move all the negative elements to one side of the array C++
Move all the negative elements to one side of the array Hindi
Move all the negative elements to one side of the array Hindi
Checkout the series: 🔥🔥🔥
👉 Recursion : • Recursion
👉 Stack and Queue : • Stack And Queue
👉 Greedy : • Greedy
👉 Leetcode contests : • Leetcode contests
👉 Leetcode June Challenge : • Leetcode June Challenge
👉 Leetcode July Challenge : • Leetcode July Challenge
LIKE | SHARE | SUBSCRIBE 🔥🔥😊
i think ,you didn't notice that it is asked in the question that order should be preserve
I saw your comment in other video on same problem ( did you find the proper solution yet, I am also trying to find the right video )
Exactly
But the order of positive and negative numbers will not remain same as before
is there any way to maintain the order of numbers also withO(1) space complexity
Given an array of positive and negative numbers, arrange them in an alternate fashion such that
every positive number is followed by a negative and vice-versa maintaining the order of appearance.
The number of positive and negative numbers need not be equal. Begin with a negative number.
If there are more positive numbers, they appear at the end of the array. If there are more negative
numbers, they too appear at the end of the array.
Input 1:
N = 6
arr[] = {1, 2, 3, -4, -1, 4}
Output 1:
arr[] = {-4, 1, -1, 2, 3, 4}
Inspiration..... Came here from linked in thank you for so much valuable content ❤️ 😊 from this video 📹 permanent viewer💐❤️
Thank you so much😊
nice but have you noticed in example of gfg they maintain the order
Valuable content💯
great learning...
Glad to hear that. Thank you :)
actually there is a pattern in these types of problems when we want to make left side different and right side different .In this question we have to shift negative elements to the left side and positive elements to the right side ,if it is given we have to put all odd numbers first and then all even numbers after OR if it is given we have to put all 0's b before and then after 1's ,So there is a pattern in these type of problems . In these type of problems its better to use partition function of quicksort algorithm.
Correct me if I am wrong !!
Yes you are right, we can use quick sort approach as well
@@AyushiSharmaDSA description me iska code bhejdo
Well explanation thank you mam
Thank you Priya, glad it was helpful 🤗
How we can do this problem if we have to maintain the Order of elements
Ayushiii....?
I really like your teaching when you teach us,,
NICE SUPER EXCELLENT MOTIVATED
order maintain is only the problem
Hey great videos !! came here after your interview. Never stop
Yes. Thank you so much😊😊
nice explanation
thank you :)
your algorithm is not giving desired output for {-12, 11, -13, -5, 6, -7, 5, -3, -6} this input
output should be : -12 -13 -5 -7 -3 -6 11 6 5
but output produced is : -12 -6 -13 -5 -3 -7 5 6 11
Try it ............
same order ke liye galat ho jaaega
iske liye array bnaa lo pehla pehle saare positive store krao then negative aur uske baad ek for lgaa ke..purane araay ko with every i same kraa do
@@adityatiwari6068 Bhai may sab bhul gaya time huwa bhaut solve karke ,btw thanks 😂
Hlw Congratulations Ayushi maam for cracking walmart....
Maam m in my 4 sem and 5 is going to start...
Currently m completing the love babber sheet and also the apna college DSA serious... It will take 5 months time.
M also starting a project on Web development ( making a college website) and i have 3 🌟 in cp
M preparing for a product based company... Only 2 years are left...
Please can you suggest me something... I've not done any internship yet... 😞
You are doing great in dsa, for internship, make good projects in any framework in which you want internship in. And then apply on internshala and other sites
@@AyushiSharmaDSA thanks maam 😊
this solution does not maintain order of elements
Yes
That's not the requirement
please make a seperete video on code with dry run.
thank a lot ,it was very helpful
Welcome Aman :). I'm glad it was helpful.
But the order is not maintained
Thank you for great explanation sister👌👌👌👌
Welcome :)
Thank you 👍
Welcome Jeevan, 😊
Hello mam! I watched your interview with Ankush Sir! I am also learning Flutter. So wanted to ask through which CZcams channels/Course did you learn Flutter. Did you also learn Web Development?
Net ninjas and mtech viral for flutter, for angular and react - thapa technical and Codevolution
@@AyushiSharmaDSA Thanks🙏
thanks miss sharma.
Nice explaination :)
Thank you Riti 😃
Aap toh wahi ho didi, Notes waali, Thankyou soo much for your notes.. Also, thankyou ayushi Di for you invaluable Resource. Both of you are great for providing such great stuff for free. Dil se bada waala thankyou..
@@nikhilflautist Thankyou ❤️😅
very nice
Heyqqq can i get whole dsa sheet of love babber
Wow mam अगर आप ऐसे ही रोज 4 क्वेश्चन कराएंगी तो शीट 3 महीने में खत्म हो जाये😊
Will try my best😀👍🏻
this approach is wrong because the ordering is not correct .
we have to maintain the order in which element is appearing therefore your solution would not pass all the test cases
yeah you are right
Good attempt but incorrect Approach. Order is not preserved here. We are expected to preserve order of negatives as well as positives.
mam ,what if the array element has one or more zero values.
Mam why can't we do this question with sorting ?
is sorting also correct?
I think it's wrong as the order of elements is not preserved
Hi would you please tell me how is the coding ninjas DSA in python please explain I am in entering in 3rd yr of production engineering kindly waiting for your reply
Hi, coding ninjas dsa course in cpp is great, but I don't know about in python. It will be good anyways :)
What about ordering of elements 😀
Didi code thoda massive or big ho jayega but concept samj aa gaya
Great :)
Didi, Isme partition bhi use kar skte hai n pivot rakhkar?
yes
wrong approach..... answer are not matching by following ths algo
order is not preserved
Girl where is the order?