Ones and Zeroes

  • 0

    Click here to see the full article post

  • 0

    Very good solutions. Thanks!

  • 0

    In Approach #5 Dynamic Programming:
    "choosing to put this string in any of the subset possible by using the previous strings traversed so far will impact the element denoted by dp[i][j] for i and j satisfying
    m ≤ i ≤ x, n ≤ j ≤ y"

    isn't the condition supposed to be x ≤ i ≤ m, y ≤ j ≤ n ?

  • 0

    @mnm Thanks for pointing this out. I've updated the conditions now.

  • 0

    Shouldn't inner loop run for strs.length in brute force approach instead of 32?

  • 0

    @pshaikh You are right. I have corrected it.

  • 0

    In the DP solution, why cant the loop be started the other way i.e

            for (int zeroes = count[0]; zeroes <= m ; zeroes++)
                for (int ones = count[1]; ones <= n; ones++)

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.