Handling Sum Queries After Update
Keep the count of ones in nums1 in a lazy segment tree, so a range flip costs O(log n) and the sum of nums2 follows from that count.
Keep the count of ones in nums1 in a lazy segment tree, so a range flip costs O(log n) and the sum of nums2 follows from that count.