C# Easy solution beat 90%
IntuitionTo approach this problem, we need to break down what the zero replacement means. Every zero has a minimum value of one when replaced, which means to ge
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
To approach this problem, we need to break down what the zero replacement means. Every zero has a minimum value of one when replaced, which means to get the minimum value we should add the number of zeros and the number sum on both sides and take the maximum as long as there are zeros to replace with.
# Approach
<!-- Describe your approach to solving the problem. -->
Create 4 variables for the sums and the count of zeroes. Iterate through the two arrays and calculate the sum while keeping track of all the zeroes.

Then we do a comparison.
if the sums + number of zeroes is equal on both sides, we just return either (sum +zeroes) since we will have the same minimum either way. If one of the sides is bigger, we check if we have any zeroes to replace with, if we do, we can simply return the value of the larger side + zeroes. Otherwise, we return -1 since we aren't able to replace.
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
Time Complexity is O(N + M) since we run through both arrays once.
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
Space Complexity is O(1) since we only keep track of the sums and the number of zeroes.
# Code
```csharp []
public class Solution {
    public long MinSum(int[] nums1, int[] nums2) {
        int numZerosInOne = 0;
        int numZerosInTwo = 0;
        long preZeroSumOne = 0;
        long preZeroSumTwo = 0;
        for(int i=0; i< nums1.Length; i++)
        {
            if(nums1[i] == 0)
            {
                numZerosInOne++;
            }
            else
            {
                preZeroSumOne+=nums1[i];
            }
        }
        for(int j=0; j< nums2.Length; j++)
        {
            if(nums2[j] == 0)
            {
                numZerosInTwo++;
            }
            else
            {
                preZeroSumTwo+=nums2[j];
            }
        }

        if(preZeroSumOne + numZerosInOne == preZeroSumTwo + numZerosInTwo)
        {
            return preZeroSumOne + numZerosInOne;
        }
        if(preZeroSumOne + numZerosInOne < preZeroSumTwo + numZerosInTwo)
        {
            if(numZerosInOne > 0)
            {
                return preZeroSumTwo + numZerosInTwo;
            }
        }
        else if(preZeroSumTwo + numZerosInTwo < preZeroSumOne + numZerosInOne)
        {
            if(numZerosInTwo > 0)
            {
                return preZeroSumOne + numZerosInOne;
            }
        }
        return -1;
    }
}
```
['C#']