Similarly, mark occupied on girl’s entry only when a single value is marked occupied and having maximum width.Įfficient Approach: To optimize the above approach, the idea is to use a priority queue. Naive Approach: The simplest approach is to take an array of pairs of size N and mark it occupied on every boy’s entry into the bus if both pair values are marked vacant and have the minimum width. Input: N = 3, W = first, before moving on to the solution. In case you wish to attend live classes with experts, please refer DSA Live Classes for Working Professionals and Competitive Programming Live for Students. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Stack Data Structure (Introduction and Program)Īttention reader! Don’t stop learning now.Write a program to reverse an array or string.Choose maximum weight with given weight and value ratio.Find Maximum dot product of two arrays with insertion of 0’s.Find maximum sum array of length less than or equal to m.Maximum Product Subarray | Added negative product case.Maximum Product Subarray | Set 2 (Using Two Traversals).Largest subarray with equal number of 0s and 1s.Find the length of largest subarray with 0 sum.