Solved LeetCode 3432 with prefix sums and modular arithmetic

💡 Day 96 of My #100DaysOfCode Challenge Today’s problem: LeetCode 3432 – Count Partitions with Even Sum Difference ⚙️ 📘 Problem Statement: Given an integer array nums, we need to count the number of ways to partition it into two non-empty parts such that the difference between their sums is even. ✅ Approach: Calculate the total sum of the array. Traverse the array while maintaining a running left sum. At each partition index, compute the right sum = totalSum - leftSum. Check if (leftSum - rightSum) is even → if yes, increase the count. 💻 Time Complexity: O(n) 🧠 Space Complexity: O(1) 🔥 Key Learnings: Strengthened understanding of prefix sums Practiced modular arithmetic in array partitions Improved analytical thinking on even-odd relationships #LeetCode #Python #CodingChallenge #100DaysOfCode #ProblemSolving #DataStructures #Algorithms #LearningEveryday

  • graphical user interface, text, application, email

To view or add a comment, sign in

Explore content categories