💡 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
Solved LeetCode 3432 with prefix sums and modular arithmetic
More Relevant Posts
-
🚀 Day 3 of #100DaysofDSA Today’s focus was on the “Set Matrix Zeroes” problem — a classic array-matrix question that tests both logic and optimization thinking It began with the brute-force idea: storing all zero positions and then marking corresponding rows and columns later. It works but takes O(m × n) time and O(m + n) extra space. Next, then explored a better approach using two auxiliary arrays to track which rows and columns should be zeroed. This improved the clarity but still consumed additional memory and space. Finally, then to reduce the complexity I tackled the optimal solution, which achieves O(1) extra space by using the first row and first column of the matrix itself as markers. A small Boolean flag handles the edge case when the first row contains a zero. This subtle observation transforms the logic completely — turning a memory-heavy method into a clean in-place algorithm. It was a good reminder that optimization isn’t just about speed — it’s about finding elegance in constraints. #100DaysOfDSA #MatrixProblems #Optimization #SpaceComplexity #Python #ProblemSolving
To view or add a comment, sign in
-
-
✅ Learned to solve “Remove Duplicates from Sorted Array” (in-place, O(n) time, O(1) space)! Sorted input means every duplicate sits next to its twin—perfect setup for the two-pointer pattern: scan once, write uniques forward, and return the count k while keeping the first k positions clean and ordered. What clicked: - Two pointers: one scans, one writes uniques forward - Skip repeats deterministically thanks to sorting - Edge cases covered: empty array, all duplicates, negatives, mixed ranges Level-ups next: “Remove Duplicates II” (allow at most twice) and “Remove Element” to deepen the pattern muscle. What’s your favorite twist on this technique? 🚀 #LeetCode #TwoPointers #Arrays #InPlace #DSA #Algorithms #InterviewPrep #ProblemSolving #TimeComplexity #CodingChallenge #Python #SoftwareEngineering
To view or add a comment, sign in
-
-
Day 30 / 100 – Majority Element II (LeetCode #229) Today’s challenge was all about identifying numbers that appear more than ⌊ n/3 ⌋ times in an array. This problem was a great way to explore the Boyer–Moore Voting Algorithm, an elegant and efficient method to find potential majority elements without using extra space. 🔍 Key Learnings Understanding how counters and candidates evolve in an iterative approach Strengthening logic for pattern recognition and frequency analysis Realizing how efficient algorithms can reduce time and memory usage 💭 Thought of the Day Consistency isn’t just about showing up — it’s about learning smarter each day. Every new problem isn’t a repetition; it’s a refinement of logic and discipline. 🔗 Problem Link:https://lnkd.in/gfiGVueC #100DaysOfCode #Day30 #LeetCode #Python #ProblemSolving #CodingChallenge #DataStructures #Algorithms #LearningJourney #CodeEveryday #TechGrowth
To view or add a comment, sign in
-
-
Interested in single taxon abundance across all published #EMOBON data? Check out the newest "Taxonomy Finder" dashboard, which gives you: - filtered abundance table for substring/exact match/NCBI tax ID search - displays the abundance as hue on the beta diversity plot either on your selected taxonomic level, or by default on "phylum" level. https://lnkd.in/dSPjXtaD #emobon #embrc #ccmar #vre #python #panel
To view or add a comment, sign in
-
-
🔍 Day 44 DSA Challenge – Problem #33: Search in Rotated Sorted Array 📌 Problem Statement: Given a sorted array nums that may have been rotated at an unknown pivot, find the index of a target value. Return -1 if the target doesn’t exist. The solution must run in O(log n) time. ⚙️ How I Solved It: Applied a modified binary search: Identify which half (left or right) is sorted. Narrow the search to the half where the target could exist. Repeat until the target is found or search space is exhausted. 📊 Performance Stats: ⏱ Runtime: 0 ms (⚡ beats 100%) 💾 Memory: 12.65 MB (beats 42.49%) ✅ Testcases Passed: 196 / 196 🧠 Key Takeaway: Understanding array properties like rotation and leveraging binary search ensures optimal search performance in logarithmic time. #LeetCode #BinarySearch #RotatedArray #Problem33 #Python #DSA #100DaysOfCode #CodingJourney
To view or add a comment, sign in
-
-
Today I solved LeetCode 3321 - Find X-Sum of All K-Long Subarrays II (Hard) #day14 of #1001DaysOfCode The challenge is to compute the “x-sum” for every subarray of length k. Instead of simply summing values, we first: Count occurrences of each number in the subarray Select the top x most frequent elements (breaking ties by choosing the larger value) Then sum only those selected elements with all their occurrences A direct recalculation for every sliding window would be too slow, so the key idea was to maintain frequency counts incrementally and keep the top-x elements efficiently balanced using two heaps. To solve it, I used: A sliding window to move across the array efficiently A frequency map to track counts Two heaps (in for top-x elements, out for remaining elements) A dynamic rebalancing step to ensure correctness as counts change Detailed explanation + code here: https://lnkd.in/dD4e5WNh #LeetCode #Python #DataStructures #Heaps #Algorithms #CodingChallenge #SoftwareEngineering #CompetitiveProgramming
To view or add a comment, sign in
-
-
#Week3 | Sorting Algorithms: The Foundation of Efficient Data Handling This week, I dove deep into the world of sorting algorithms, exploring how different approaches tackle the fundamental problem of arranging data. Here’s what I covered: * Implemented Merge Sort, a classic divide-and-conquer algorithm. * Implemented Quick Sort, discovering the importance of pivot selection. * Implemented Heap Sort, leveraging the power of heap data structures. Tech Stack / Tools Used: Python, Jupyter Notebook Key Insights / Learnings: Understanding the trade-offs between these algorithms in terms of time complexity, space complexity, and stability was the key takeaway. Merge sort is stable but needs extra space, Quick sort is fast but unstable, and Heap sort is in-place. This Week’s Plan: Next, I'll be exploring another fundamental concept: search algorithms. Reflections / Takeaway: Mastering these sorting algorithms is a crucial step in writing efficient and scalable code. Project / Repo Link: https://lnkd.in/gTaqbQKc #AIJourney #MachineLearning #Python #DataStructures #Algorithms #SortingAlgorithms #LearningInPublic #12WeeksAIReset
To view or add a comment, sign in
-
-
Day 68: Search in 2D Sorted Matrix (Search Space Reduction) 🔎 I'm continuing the streak on Day 68 of #100DaysOfCode with a challenging matrix search problem! The task is to find a target value in an $m \times n$ matrix where both rows and columns are sorted in ascending order. The key to solving this efficiently is Search Space Reduction. Instead of performing a standard search, my solution uses a smart traversal technique: Starting Point: I begin the search at the top-right corner of the matrix. Decision Logic: If the current value equals the target, we stop. If the current value is greater than the target, the entire current column can be eliminated, so we move left. If the current value is less than the target, the entire current row can be eliminated, so we move down. This strategy eliminates one row or one column in every step, guaranteeing an optimal O(m + n) time complexity and O(1) extra space. #Python #DSA #Algorithms #Matrix #Search #100DaysOfCode #ProblemSolving
To view or add a comment, sign in
-
-
✅ Day 96 Completed – Inorder Traversal Today’s challenge was all about performing Inorder Traversal on a binary tree — a fundamental operation in tree data structures. 🧩 Concept: Inorder traversal visits nodes in the Left → Root → Right order. The task was to implement it without using recursion or an explicit stack, making it an interesting optimization problem. 💡 Approach: The solution uses the Morris Traversal algorithm, which cleverly utilizes threaded binary trees to achieve traversal in O(1) space complexity. It creates temporary links (threads) to predecessor nodes. Once a node’s left subtree is visited, the link is removed, ensuring no extra memory usage. ⚙️ Key Highlights: Space-efficient (no recursion/stack) Time complexity: O(N) All test cases passed ✅ (1111/1111 with 100% accuracy) 🌱 Takeaway: This problem deepened my understanding of space-optimized tree traversal techniques and their practical applications. #100DaysOfCode #Day96 #GeeksforGeeks #Python #DataStructures #BinaryTree #InorderTraversal
To view or add a comment, sign in
-
-
✅ LeetCode 3446 – Sort Matrix by Diagonals Successfully solved another interesting matrix manipulation problem! 🧩 Problem Summary: Given an n × n matrix, the task is to sort: The bottom-left diagonals (including the main diagonal) in non-increasing order. The top-right diagonals in non-decreasing order. 💡 Approach: Use a dictionary to group elements by diagonal index (j - i). Sort each diagonal individually based on its position (top or bottom triangle). Reconstruct the matrix by placing back the sorted values. ⚙️ Key Concepts: Matrix traversal Diagonal indexing (j - i) Sorting and reconstruction 📊 Result: ✅ Accepted with 0 ms runtime 💪 Optimized, clean, and easy-to-read solution #LeetCode #Python #ProblemSolving #CodingChallenge #DataStructures #Algorithms #Matrix #DeveloperJourney
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development