𝐂𝐨𝐝𝐞𝐟𝐨𝐫𝐜𝐞𝐬 𝐑𝐨𝐮𝐧𝐝 983 : 𝐄𝐝𝐢𝐭𝐨𝐫𝐢𝐚𝐥 : 𝐀-𝐃 𝐀 - Minimum will be number of one’s mod 2. For Maximum, if number of one’s is greater than is less than or equal to n, then answer will be number of one’s else the answer will be 2*n - no_of_ones. 𝐁 - if k is even then just break like 1, k, k+1 If k is odd then break like 1, 2, k, k+1, n 𝐂 - sort the array, start iterating from left to right get the rightmost index j for index i such that a[j]<a[i]+a[i+1], hence you don’t need to change anything in this window and have to change all the elements outside this window which will be first i-1 elements and last n-j elements, maintain a minimum and update for each i. 𝐃 - First get those nodes that are connected to 0 directly, after that maintain a set of leaf nodes, for any new number to check for its parent, First check with the biggest leaf node, if it turns out to be true, replace the biggest leaf node with the node for which you were checking as now it will be the leaf node Otherwise, start checking from smaller leaf nodes. If a leaf node you are checking now is not the parent of this current node, you just pop out this leaf node as the subtree of this branch is already over, and no new node will be connected to this in the future. Then, check for the next bigger leaf node until you find the parent, then repeat process 1.
bas krdo bhai kuch hmare liye bhi chod do 😆, itna chaapna achchi baat thode hi h
Very helpful 😸
Love this
Undergrad at BIT Mesra(BIT'27)||3⭐(max 1637) at Codechef ||LeetCode(max 1646)||Web Development Enthusiast||CPP+DSA
1moMy intuition of C is also the same . But it gives the wrong answer. I think there is an implementation mistake .Could you share the submission link for the C problem.