Skip to content
0:00 / 0:00

#kadane'salgorithm#interviewbit#geeksforgeeks

Flip | InterviewBit + GFG Solution | Algorithm Explanation by alGOds!!

alGOds

4.7K subscribers • 2 videos on Hallway

YouTube
  • Recommended by 1 person: 1 on Stack Overflow and its sister sites.
  • Presented by Varun Bajlotra

Intermediate. Assumes working knowledge.

17K views6 years ago1 recommendation

Computer scienceAlgorithmsData structures

Varun Bajlotra explains an efficient algorithm to find the subarray to flip to maximize the number of one bits.

In this video, Varun Bajlotra has explained the O(n) approach for finding the number of flips to maximize the setbits. InterviewBit Question Link - interviewbit.com/problems/flip/ GFG Question Link - practice.geeksforgeeks.org/problems/flip-bits/0 C++ Solution for Reference – ide.geeksforgeeks.org/7jg1T4CTmt Feel free to ask any of your doubts and discuss your attempts related to this question in the comments section 😇. Join this telegram channel for regular updates : t.me/alGOdsYouTube Join this telegram group for doubts and discussions : t.me/joinchat/PqjeMhz0MBR-tg31OK2Dsg Do like and subscribe to our channel and click the bell icon so you don’t miss any future videos!!. Don’t forget to tell us about the Questions you need an explanatory video for in the comments section. We’ll definitely take care of it😁. Here is the Subscription Link : youtube.com/c/algods99 Connect with us on Gmail : algods.99@gmail.com The contributors to this channel and their profile links are enlisted below 1) Vishesh Aggarwal: LinkedIn :- linkedin.com/in/vishesh-aggarwal-830b5416b 2) Vaibhav Varshney: LinkedIn :- linkedin.com/in/vaibhav-varshney/ 3) Vagish Yagnik: LinkedIn :- linkedin.com/in/vagish-yagnik-9203b0172/ 4) Vishesh Jain: LinkedIn :- linkedin.com/in/vishesh-jain-138097174/ 5) Achint Dawra: LinkedIn :- linkedin.com/in/achint-dawra-ba9550168/ 6) V Sriram: LinkedIn :- linkedin.com/in/sriram-v-08b098170/ 7) Varun Bajlotra: LinkedIn :- linkedin.com/in/varun-bajlotra-17715a170/ 8) Vikas Yadav: LinkedIn :- linkedin.com/in/vikas-yadav-b432b5107/

Why it's here

1 person recommends this

What people say. Recommended as a clear explanation of using Kadane's algorithm to solve the bit flipping maximization problem.

Varun Bajlotraon Stack Overflow • Recommends

On “Find number of bits to be flipped to get maximum 1's in array”

The solution uses Kadane's Algorithm. We have to pick that substring where there are maximum number of 0s and minimum number of 1s, i.e., substring with max(count(0)-count(1)). So that after the flip, we can get maximum number of 1s in the final string. Iterate over the string and keep a count. Increment this count whenever we encounter a 0 and decrement it when we encounter 1. The substring which will have the maximum value of this count will be our answer. Here's a video by alGOds which explains the approach nicely. Do watch it if you have any doubts. Link : link to this video