Mayank Pushpjeet’s Post

View profile for Mayank Pushpjeet, graphic

Upcoming SDE-1 at Flipkart || Former SDE intern at Astrotalk || Former Intern at Adobe || Candidate Master at Codeforces (max rating-1949) || 5 ⭐ at Codechef || Guardian at Leetcode || IIT Kanpur

𝐂𝐨𝐝𝐞𝐟𝐨𝐫𝐜𝐞𝐬 𝐑𝐨𝐮𝐧𝐝 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.

  • No alternative text description for this image
Krish Saini

Undergrad at BIT Mesra(BIT'27)||3⭐(max 1637) at Codechef ||LeetCode(max 1646)||Web Development Enthusiast||CPP+DSA

1mo

My 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.

Like
Reply
Mohd Fahad

Former Quant Intern @FuturesFirst | Mathematics & Sc. Computing @IITKanpur | Expert @CodeForces [1803] | 5🌟 @CodeChef [2084] | Guardian @LeetCode [2181]

1mo

bas krdo bhai kuch hmare liye bhi chod do 😆, itna chaapna achchi baat thode hi h

Like
Reply
Shan Sihogia

pre-final year @ Indian Institute of Information Technology(IIIT), Sonepat ||Full-stack development enthusiast || DSA || Competitive coder

1mo

Very helpful 😸

Arnab Manna

B.Tech (CSE) @ Techno India Group | Full Stack Web Developer | Expert @ Codeforces | Global Rank in Top 50 @ GeeksforGeeks | Passionate about Java, TypeScript, React.js, Node.js, Firebase, & Tailwind CSS.

1mo

Love this

See more comments

To view or add a comment, sign in

Explore topics