🚀 Day 7/60 — LeetCode Discipline Problem Solved: Contiguous Array (Revision) Difficulty: Medium Today’s practice focused on identifying equal 0s and 1s in a binary array using prefix sum and hashmap optimization. Revisiting this problem reinforced how transforming the problem space can unlock efficient linear-time solutions. 💡 Focus Areas: • Strengthened prefix sum transformation technique • Practiced hashmap-based frequency tracking • Improved subarray pattern recognition • Focused on writing clean and efficient logic ⚡ Performance Highlight: Achieved solid runtime performance on submission. Quiet consistency, deeper patterns, sharper intuition. #LeetCode #60DaysOfCode #100DaysOfCode #DSA #PrefixSum #HashMap #Algorithms #DataStructures #ProblemSolving #CodingJourney #SoftwareEngineering #TechCareers #Programming #Developers #CodingLife
LeetCode Discipline: Contiguous Array Solution with Prefix Sum and Hashmap
More Relevant Posts
-
Day 42 on LeetCode — Merge Sorted Array (Two Pointer Approach) ✅ Today’s problem focused on efficient in-place array manipulation using the two-pointer technique. 🔹 Approach Used in My Solution The key insight was to compare elements from the back of both arrays instead of the front. Since nums1 already has extra space at the end to accommodate elements from nums2, we can fill the array from the last index backwards. Key points in the logic: • Initialize pointers at the end of the valid elements of nums1 and nums2 • Compare the elements and place the larger one at the back of nums1 • Move the pointers accordingly until all elements are merged • This allows the final sorted array to be stored directly in nums1 This strategy avoids unnecessary shifting of elements and keeps the solution efficient. ⚡ Complexity: • Time Complexity: O(m + n) • Space Complexity: O(1) (in-place merge) 💡 Key Takeaways: • Learned how working from the back can simplify in-place merges • Strengthened understanding of the two-pointer technique • Practiced optimizing array operations without using extra space #LeetCode #DSA #Algorithms #DataStructures #TwoPointers #Arrays #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
To view or add a comment, sign in
-
-
Day 40 on LeetCode — Longest Consecutive Sequence ✅ Today’s challenge was about finding the longest sequence of consecutive numbers in an unsorted array. 🔹 Approach Used in My Solution In my implementation, I first sorted the array, which makes consecutive numbers appear next to each other. After sorting, I traversed the array once to track the current streak of consecutive numbers. Key points in the logic: • Skip duplicates to avoid breaking the sequence • Increase the counter when the current number is exactly previous + 1 • Reset the counter when the sequence breaks and update the longest streak This approach keeps the implementation simple, readable, and effective. ⚡ Complexity: • Time Complexity: O(n log n) due to sorting • Space Complexity: O(1) (excluding sorting space) 💡 Key Takeaways: • Sorting can simplify many sequence detection problems • Careful handling of duplicates is important in consecutive sequence problems • Reinforces writing clean traversal logic after preprocessing #LeetCode #DSA #Algorithms #DataStructures #Arrays #Sorting #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
To view or add a comment, sign in
-
-
Day 43 on LeetCode — Squares of a Sorted Array ✅ Today’s problem focused on two-pointer technique and handling absolute values for efficient array transformation. 🔹 Approach Used in My Solution The goal was to return a sorted array of squares from a non-decreasing sorted input array, which may contain negative numbers. Key points in the logic: • Use two pointers at the start (left) and end (right) of the array • Compare absolute values of elements at both ends • Place the larger square at the current last position in the result array (pos) • Move the pointer of the larger absolute value and fill the result array from back to front • Continue until all elements are squared and placed This ensures a single-pass O(n) solution without extra sorting. ⚡ Complexity: • Time Complexity: O(n) • Space Complexity: O(n) 💡 Key Takeaways: • Practiced the two-pointer technique for array transformations • Learned to handle negative numbers when squaring • Strengthened understanding of in-place logic using a separate result array #LeetCode #DSA #Algorithms #DataStructures #Arrays #TwoPointers #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
To view or add a comment, sign in
-
-
🚀 Day 4 of 100 Days LeetCode Challenge. Problem: Special Positions in a Binary Matrix Today’s problem focused on matrix traversal + counting logic—simple concept, but requires careful observation. 💡 Key Insight: A position (i, j) is special if: mat[i][j] == 1 All other elements in the same row and column are 0 🔍 Efficient Approach: Count number of 1’s in each row Count number of 1’s in each column A position is special only if: Row count = 1 Column count = 1 👉 This avoids unnecessary repeated checks and improves efficiency. 🔥 What I Learned Today: Preprocessing (row & column counts) simplifies problems Avoid brute force → think in terms of frequency/counting Clean logic > complex code 📈 Challenge Progress: Day 4/100 ✅ Staying consistent! LeetCode, Matrix Problem, Arrays, Counting Technique, DSA Practice, Coding Challenge, Problem Solving, Algorithm Thinking, Optimization #100DaysOfCode #LeetCode #DSA #CodingChallenge #Matrix #ProblemSolving #TechJourney #ProgrammerLife #SoftwareDeveloper #CodingLife #LearnToCode #Developers #Consistency #GrowthMindset #InterviewPrep
To view or add a comment, sign in
-
-
Day 41 on LeetCode — Count the Number of Consistent Strings ✅ Today’s problem focused on hash maps and efficient character validation in strings. 🔹 Approach Used in My Solution The idea was to first store all allowed characters in a hash map for quick lookup. After that, I iterated through each word and checked whether every character exists in the allowed set. Key steps in the logic: • Store characters from the allowed string in an unordered_map • Traverse each word in the words array • Check every character of the word against the map • If a character is not allowed, mark the word as invalid • Count only the words where all characters are valid This approach keeps the lookup efficient and the implementation straightforward. ⚡ Complexity: • Time Complexity: O(n × m) (n = number of words, m = average length of each word) • Space Complexity: O(1) (since the character set is limited) 💡 Key Takeaways: • Practiced using hash maps for fast membership checks • Strengthened understanding of string traversal and validation • Reinforced building clean and readable solutions for character-based problems #LeetCode #DSA #Algorithms #DataStructures #HashMap #Strings #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
To view or add a comment, sign in
-
-
LeetCode Win Today 🚀 Solved “Apply Operations to an Array” with a simple two-pass approach. ⚡ Runtime: 0 ms (Beats 100%) Approach: 🔹 Pass 1: Traverse the array If nums[j] == nums[j-1] → Double the left element → Set the right element to 0 🔹 Pass 2: Move all zeros to the end using a two-pointer technique. 💡 Key Insight: Instead of solving everything in one complex loop, split the problem into two clean steps. 📊 Complexity: • Time → O(n) • Space → O(1) (in-place) Consistent practice. Clear thinking. Better code every day. 🧠⚡ #leetcode #dsa #algorithms #datastructures #coding #programming #python #softwareengineering #computerscience #tech #codinglife #problem-solving #100daysofcode #developers #codingjourney #techcommunity 🚀
To view or add a comment, sign in
-
-
🚀 Day 18 | 100 Days of Coding Challenge #DrGViswanathanChallenge 📘 Problem Solved: Subsets II (LeetCode) 🔧 Approach Used (Backtracking + Sorting): • Sorted the array to handle duplicates • Generated subsets recursively • Skipped duplicate elements at the same recursion level • Used backtracking (Do → Explore → Undo) ⏳ Complexity: Time: O(2ⁿ) Space: O(n) (recursion stack) 🧠 Key Learning: Handling duplicates correctly is crucial in subset generation problems. Sorting + smart skipping avoids repeated subsets efficiently. 📂 Topics Covered: Backtracking, Recursion, Arrays, Power Set #100DaysOfCode #DSA #CPP #LeetCode #CodingJourney #CompetitiveProgramming
To view or add a comment, sign in
-
-
Day 36 on LeetCode — Intersection of Two Arrays (Using Hash Table) ✅ Today’s problem focused on applying hash tables for efficient lookup and duplicate handling. 🔹 Intersection of Two Arrays Solved by leveraging a hash table (unordered_set) to store elements from the first array for O(1) average lookup time. Then iterated through the second array to check which elements exist in the set and added them to the result while ensuring unique values only. This approach significantly improves efficiency compared to brute-force methods. ⚡ Complexity: • Time Complexity: O(n + m) • Space Complexity: O(n) 💡 Key Takeaways: • Strengthened understanding of hash-based lookups • Learned how to efficiently find common elements between datasets • Practiced writing optimized solutions using hash tables #LeetCode #DSA #Algorithms #DataStructures #HashTable #HashSet #Programming #Coding #SoftwareEngineering #ComputerScience #ProblemSolving #CodingPractice #Cpp #STL #TechJourney #DeveloperLife #CodingDaily #CodeNewbie #LearnToCode #BuildInPublic #100DaysOfCode #AlgorithmPractice #TechCommunity #Developers #CodingSkills #SoftwareDeveloper #EngineeringJourney
To view or add a comment, sign in
-
-
Day 64 – Lowest Common Ancestor in Binary Tree: Finding the Family Connection 🌳👥 Today's challenge explored the fundamental problem of finding the deepest node that serves as an ancestor to two given nodes in a binary tree a beautiful exercise in recursive traversal and parent child relationships. 🌳 Lowest Common Ancestor in a Binary Tree I approached this problem using recursive depth first search with a clear, elegant logic. Starting from the root, I traversed downward if the current node matched either target, I returned it as a potential ancestor. I then recursively searched the left and right subtrees. If both sides returned non null values, the current node was the lowest common ancestor. If only one side returned a value, I propagated that result upward. This approach achieved O(n) time with O(h) recursion stack space, where h is the tree height. #LeetCode #Coding #Algorithms #DataStructures #BinaryTree #LCA #Recursion #TreeTraversal #ProblemSolving #SoftwareEngineering #Programming #100DaysOfCode
To view or add a comment, sign in
-
🚀 Day 24/60 — LeetCode Discipline Problem Solved: Symmetric Tree (Revision) Difficulty: Easy Today’s practice focused on revisiting a classic binary tree problem — checking whether a tree is symmetric around its center. The key idea is to treat the left and right subtrees as mirror images and recursively compare their corresponding nodes. By verifying both structure and node values simultaneously, the algorithm determines whether the tree maintains perfect symmetry. Problems like this highlight how recursion naturally fits tree-based structures and helps simplify complex comparisons. 💡 Focus Areas: • Strengthened recursive tree traversal • Practiced mirror comparison of subtrees • Improved understanding of binary tree symmetry • Reinforced recursive problem-solving patterns • Focused on writing clean and structured logic ⚡ Performance Highlight: Achieved 0 ms runtime (100% performance) on submission. Consistent practice across arrays, strings, stacks, bit manipulation, and now tree structures continues to deepen my overall algorithmic intuition. #LeetCode #60DaysOfCode #100DaysOfCode #DSA #BinaryTree #Recursion #Algorithms #DataStructures #ProblemSolving #CodingJourney #SoftwareEngineering #Programming #Developers #TechCareers #Java
To view or add a comment, sign in
-
Explore related topics
- Leetcode Problem Solving Strategies
- LeetCode Array Problem Solving Techniques
- Approaches to Array Problem Solving for Coding Interviews
- How to Improve Array Iteration Performance in Code
- Coding Best Practices to Reduce Developer Mistakes
- How to Use Arrays in Software Development
- How to Improve Code Performance
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