Skip to content

Conversation

@anuradha8055
Copy link

Problem

LeetCode Problem 474: Ones and Zeroes

Solution

Implemented a dynamic programming solution in C++ (474.cpp).
The solution calculates the maximum number of strings that can be formed with a given number of 0s and 1s.

Approach

  • Used a 2D DP array where dp[i][j] represents the maximum number of strings using i zeros and j ones.
  • Iterated through each string to update DP values in reverse to avoid recomputation.
  • Achieves optimal time and space complexity.

Complexity

  • Time Complexity: O(n * m * l)
  • Space Complexity: O(m * l)
    (where n = number of strings, m = max zeros allowed, l = max ones allowed)

Additional Notes

  • Verified with sample test cases from LeetCode.
  • Code formatted and ready for merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant