✅ Day 88 of 100 Days LeetCode Challenge Problem: 🔹 #1252 – Cells with Odd Values in a Matrix 🔗 https://lnkd.in/g5eE9A-e Learning Journey: 🔹 Today’s problem focused on simulating row and column increment operations on a matrix. 🔹 I initialized an m × n matrix with all zeros. 🔹 For each index [ri, ci], I incremented: • All elements in row ri • All elements in column ci 🔹 After applying all operations, I traversed the matrix to count how many cells contain odd values. Concepts Used: 🔹 Matrix Simulation 🔹 Nested Loops 🔹 Conditional Counting 🔹 Basic Array Manipulation Key Insight: 🔹 Direct simulation works efficiently due to small constraints. 🔹 Each operation affects an entire row and column, so tracking increments carefully is key. Complexity: 🔹 Time: O(m × n + k × (m + n)) 🔹 Space: O(m × n) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
LeetCode Challenge Day 88: Cells with Odd Values in Matrix
More Relevant Posts
-
✅ Day 89 of 100 Days LeetCode Challenge Problem: 🔹 #1480 – Running Sum of 1D Array 🔗 https://lnkd.in/gSTZrxF7 Learning Journey: 🔹 Today’s problem focused on computing the running (prefix) sum of an array. 🔹 Instead of using an extra array, I optimized the solution by modifying the input array in-place. 🔹 Starting from index 1, I updated each element as: • nums[i] += nums[i-1] 🔹 This way, each index stores the cumulative sum up to that point. 🔹 Finally, returned the modified array. Concepts Used: 🔹 Prefix Sum 🔹 In-place Computation 🔹 Array Traversal Key Insight: 🔹 The previous element already stores the prefix sum, so we can reuse it directly. 🔹 Eliminates the need for extra space while maintaining linear time. Complexity: 🔹 Time: O(n) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
✅ Day 95 of 100 Days LeetCode Challenge Problem: 🔹 #869 – Reordered Power of 2 🔗 https://lnkd.in/gkNXaSFM Learning Journey: 🔹 Today’s problem focused on checking whether the digits of a number can be rearranged to form a power of 2. 🔹 I created a helper function to extract and store the digits of a number. 🔹 Then I sorted the digits of the input number for comparison. 🔹 Next, I generated powers of 2 iteratively and compared their sorted digit lists with the input. 🔹 If any match was found, I returned True. Otherwise, continued until the digit length exceeded the input. Concepts Used: 🔹 Digit Extraction 🔹 Sorting 🔹 Simulation of Powers of 2 🔹 Brute Force Optimization Key Insight: 🔹 Instead of generating permutations (which is expensive), sorting digits allows quick comparison. 🔹 Any valid rearrangement must have the same digit frequency as some power of 2. Complexity: 🔹 Time: O(log n * d log d) 🔹 Space: O(d) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
🗓 7 April 2026 LeetCode Problem #128 – Longest Consecutive Sequence Solved the problem of finding the longest consecutive sequence in an unsorted array. Key insight: use a set for O(1) lookups and only start counting sequences from numbers that are the beginning of a sequence. Takeaways: - Using the right data structure reduces time complexity from O(n²) to O(n). - Avoid redundant work while scanning arrays. - Handle edge cases like empty or single-element arrays efficiently. This problem reinforces how a smart approach beats brute force every time! #LeetCode #Algorithms #Python #DataStructures #ProblemSolving #Coding #TechLearning
To view or add a comment, sign in
-
-
✅ Day 97 of 100 Days LeetCode Challenge Problem: 🔹 #1281 – Subtract the Product and Sum of Digits of an Integer 🔗 https://lnkd.in/gxTAZc6U Learning Journey: 🔹 Today’s problem involved extracting digits of a number and performing two operations simultaneously. 🔹 I initialized two variables: one for product (pr) and one for sum (sm). 🔹 Using a while loop, I extracted each digit using n % 10. 🔹 Updated the product by multiplying the digit and updated the sum by adding it. 🔹 Reduced the number using integer division (n //= 10) after each step. 🔹 Finally returned the difference between product and sum. Concepts Used: 🔹 Digit Extraction 🔹 While Loop 🔹 Arithmetic Operations 🔹 Number Manipulation Key Insight: 🔹 Both product and sum can be computed in a single traversal of digits. 🔹 Efficient use of modulus and division avoids converting the number to a string. Complexity: 🔹 Time: O(d) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
The Magic of the Mirror: Image Flipping with NumPy! 🤳🔄 Day 85/100 Ever wondered how your phone 'mirrors' your selfies instantly? It’s just one line of array slicing! For Day 85 of my #100DaysOfCode, I explored Image Flipping and Mirroring. In the world of Computer Vision, an image is just a matrix, and to flip it, we simply reverse the order in which we read the rows or columns. Technical Highlights: 🔄 Axis Reversal: Mastering the [::-1] slicing syntax to reverse array indices without complex loops. 🤳 Mirror Logic: Implementing horizontal flips to simulate the front-camera 'selfie' experience. 🌊 Vertical Reflection: Creating water surface reflection effects by reversing the row order of 2D matrices. 🤖 AI Data Augmentation: Learning how flipping images is used in Machine Learning to double the size of training datasets and prevent model bias. Do check my GitHub repository here : https://lnkd.in/d9Yi9ZsC #100DaysOfCode #ComputerVision #NumPy #Python #BTech #IILM #AIML #ImageProcessing #DataAugmentation #SoftwareEngineering #LearningInPublic #WomenInTech
To view or add a comment, sign in
-
-
Day 47 of #GeekStreak60: The Binary State Machine! 0️⃣1️⃣ Tackled the "Consecutive 1's not allowed" problem on @GeeksforGeeks today. Key Learning: Counting valid combinations often looks like a backtracking problem, which leads to an O(2^n) time trap. By analyzing the strict rules of binary generation, I modeled the problem as a Finite State Machine. Because a 1 can only follow a 0, but a 0 can follow anything, I simply tracked the counts of strings ending in each digit iteratively. This completely eliminated the need to generate the strings themselves, dropping the time complexity to a highly efficient O(n) and the auxiliary space down to a perfect O(1)! (Fun fact: This strict state transition actually generates the Fibonacci sequence under the hood!) Less than two weeks left in the 60-day sprint! 🚀 #geekstreak60 #npci #coding #Algorithms #Python #DataStructures #DynamicProgramming #StateMachines #Optimization
To view or add a comment, sign in
-
-
Day 56 of #GeekStreak60: The Phantom Pointer Trick! 🕵️♂️📈 Tackled the "Sorted subsequence of size 3" problem on @GeeksforGeeks today. Key Learning: Finding an increasing triplet is easy if you use extra arrays to track minimums and maximums, but that violates the O(1) space constraint. The optimal solution is to use "Greedy State Tracking." By iterating through the array in a single pass, I maintained three variables: the absolute smallest number seen (num1), a valid middle number (num2), and a snapshot of num1 locked in at the exact moment num2 was discovered. If the loop encounters any number strictly greater than num2, the valid triplet is instantly formed! This perfectly eliminates the need for O(n) memory arrays while keeping the time complexity to a strict O(n). Just 4 days left! The logic is feeling sharper than ever. 🚀 #geekstreak60 #npci #coding #Algorithms #Python #DataStructures #Optimization #SoftwareEngineering
To view or add a comment, sign in
-
-
Solved Kth Smallest Element in a BST today Used an iterative inorder traversal (DFS with stack) to efficiently find the answer without extra space for storing nodes. Key idea: 👉 Inorder traversal of a BST gives nodes in sorted order 👉 So the k-th visited node is the answer Instead of recursion, I used a stack to simulate traversal: Go left as much as possible Process node Move right Clean, efficient, and interview-friendly ✅ Time: O(H + k) Space: O(H) (stack) Consistent practice is making these patterns feel natural 🚀 #LeetCode #DataStructures #Algorithms #Python #CodingInterview
To view or add a comment, sign in
-
-
✅ Day 98 of 100 Days LeetCode Challenge Problem: 🔹 #338 – Counting Bits 🔗 https://lnkd.in/gXdNxX66 Learning Journey: 🔹 Today’s problem focused on counting the number of 1s in the binary representation of numbers from 0 to n. 🔹 I initialized an array ans of size n+1. 🔹 For each number i, I converted it to binary using bin(i)[2:]. 🔹 Counted the number of '1' bits by iterating through the binary string. 🔹 Stored the count in ans[i] and returned the final array. Concepts Used: 🔹 Bit Manipulation (Binary Representation) 🔹 Array Traversal 🔹 String Processing 🔹 Brute Force Approach Key Insight: 🔹 Each number’s bit count can be computed independently. 🔹 Converting to binary and counting '1' works, but can be optimized further using DP or bit tricks. Complexity: 🔹 Time: O(n log n) (binary conversion for each number) 🔹 Space: O(n) #LeetCode #Algorithms #DataStructures #100DaysOfCode #Python #CodingJourney #ProblemSolving #LearningInPublic
To view or add a comment, sign in
-
-
Day 49 of #GeekStreak60: The Math Behind the Matrix! 🧮🔲 Tackled the "Print Diagonally" problem on @GeeksforGeeks today. Key Learning: When traversing a matrix, it's easy to get bogged down in complex boundary checks and nested while loops. But analyzing the actual coordinates reveals a mathematical shortcut: along any anti-diagonal, the sum of the row and column indices (i + j) is always constant! Instead of writing a messy simulation, I used this property to iterate through all possible index sums (from 0 to 2n - 2). By calculating the strict upper and lower bounds for the rows at each sum, the algorithm perfectly extracts the anti-diagonals in pure O(n²) time without a single out-of-bounds check. Algorithms become so much cleaner when you step back and look for the underlying math! 🚀 #geekstreak60 #npci #coding #Algorithms #Python #DataStructures #Matrix #Mathematics #ProblemSolving
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