VIII. Bonus. (+10 points) Given a binary string s[1..n] of length n bits (i.e., each s[i] is either 0 or 1), give an O(n
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
VIII. Bonus. (+10 points) Given a binary string s[1..n] of length n bits (i.e., each s[i] is either 0 or 1), give an O(n
VIII. Bonus. (+10 points) Given a binary string s[1..n] of length n bits (i.e., each s is either 0 or 1), give an O(n)-time algorithm that outputs a maximum-length substring r of s, such that the number of 0's in r is equal to the number of 1's. (Note that such a substring z might be the empty substring.) Recall that a substring of s is a sequence of consecutive bits in s.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!