🕵️♀️ Day 67 of #100DaysOfCode 🕵️♀️ 🔹 Problem: The Two Sneaky Numbers of Digitville – LeetCode ✨ Approach: Designed a simple nested loop comparison to uncover the two “sneaky” duplicate numbers hiding in the array. By checking every pair and exiting early once both are found, the solution ensures clarity and efficiency with minimal extra logic! ⚡ 📊 Complexity Analysis: Time Complexity: O(n²) — double traversal for pair comparison Space Complexity: O(1) — constant space for result storage ✅ Runtime: 1 ms (Beats 100.00%) ✅ Memory: 45.58 MB 🔑 Key Insight: Sometimes, the best detective work in code isn’t about fancy tricks — it’s about precision, early exits, and keeping things simple yet sharp. 🕶️ #LeetCode #100DaysOfCode #ProblemSolving #DSA #AlgorithmDesign #Array #LogicBuilding #CodingDaily #CodeJourney #Efficiency #ProgrammingChallenge
Solved Two Sneaky Numbers of Digitville with simple nested loops
More Relevant Posts
-
💡 Day 77 of #100DaysOfCode 💡 🔹 Problem: Majority Element – LeetCode ✨ Approach: Used a sorting-based strategy to quickly identify the majority element. By sorting the array, the middle element naturally becomes the majority — simple, clean, and surprisingly powerful! 🌟 📊 Complexity Analysis: ⏱ Time Complexity: O(n log n) — due to sorting 💾 Space Complexity: O(1) — constant auxiliary space ✅ Runtime: 7 ms (Beats 39.33%) ✅ Memory: 55.75 MB 🔑 Key Insight: Sometimes the smartest solution is also the simplest — a little ordering can reveal the dominant pattern hiding in plain sight. ✨ #LeetCode #100DaysOfCode #ProblemSolving #DSA #AlgorithmDesign #CodingDaily #ProgrammingChallenge #Sorting #LogicBuilding #CodeJourney
To view or add a comment, sign in
-
-
🚀 Day 2 of LeetCode – Problem #189: Rotate Array Today’s challenge was deceptively simple: rotate an array to the right by k steps. But the real twist? Doing it in-place with O(1) space complexity. 🔍 Key Takeaways: Used the three-step reversal technique: Reverse the entire array Reverse the first k elements Reverse the remaining n - k elements Learned how modular arithmetic (k % n) helps handle edge cases when k exceeds array length. 💡 What I loved: This problem teaches how a clever algorithm can turn a brute-force idea into an elegant solution. It’s not just about rotating arrays—it’s about rotating your perspective. #LeetCode #100DaysOfCode #CodingJourney #ProblemSolving #RotateArray #TechWithAniket
To view or add a comment, sign in
-
-
🔗 LeetCode 2536 – Increment Submatrices by One The task involves applying multiple range increment operations on a matrix efficiently. Instead of directly updating each cell, the problem rewards understanding difference arrays (2D prefix sums) — an elegant approach that transforms brute-force updates into constant-time range modifications. 💡 Key Takeaways: • Difference arrays simplify complex range updates with minimal computation. • 2D prefix logic is a powerful extension of array-based optimization. • Focusing on efficiency often transforms implementation-heavy problems into mathematical ones. #Day86 #LeetCodeChallenge #100DaysOfCode #DSA #CodingJourney #ProblemSolving #Matrix #PrefixSum #Optimization #Implementation
To view or add a comment, sign in
-
-
💯 Day 8/100: Number Theory Meets Greedy Logic — LeetCode 2654 Today’s challenge was deceptively simple: make every element in an array equal to 1 using only GCD-based operations. But under the hood, it’s a full-on number theory and greedy strategy test. 🔍 Problem: You can replace adjacent elements with their GCD. How many operations to make the entire array 1? 💡 Key Insights: If the GCD of the entire array isn’t 1, it’s game over. If there’s already a 1 in the array, each non-1 takes one operation. Otherwise, find the shortest subarray with GCD = 1, reduce it, then spread the 1 across the array. 🧠 What I learned: Manual GCD implementation is a must when imports fail. Greedy logic layered on top of number theory can unlock elegant solutions. Even edge cases like [2,6,3,4] reveal the importance of subarray scanning and early exits. This one sharpened my instincts for constraint-based optimization and reinforced the value of fallback logic when environments restrict imports. Onward to Day 9 — the grind continues. #100DaysOfCode #LeetCode #NumberTheory #GreedyAlgorithms #ScarCodes #ProblemSolving #TechJourney #CodeChallenge
To view or add a comment, sign in
-
-
🎯 Day 81 of #100DaysOfCode 🎯 🔹 Problem: Reverse Only Letters – LeetCode ✨ Approach: Used a two-pointer strategy to reverse only the alphabetic characters while keeping all non-letter characters in their original positions. By moving pointers inward and swapping only when both characters are letters, the solution stays efficient and elegant! 🔄✨ 📊 Complexity Analysis: ⏱ Time Complexity: O(n) — each character visited at most once 💾 Space Complexity: O(n) — due to character array construction ✅ Runtime: 0 ms (Beats 100% 🚀) ✅ Memory: 42.96 MB 🔑 Key Insight: Sometimes, all you need is smart pointer movement — not everything needs to be reversed, only the right pieces. #LeetCode #100DaysOfCode #DSA #TwoPointers #StringManipulation #ProblemSolving #CleanCode #AlgorithmDesign #CodingChallenge
To view or add a comment, sign in
-
-
🌟 Day 84 of #100DaysOfCode 🌟 🔹 Problem Solved: Check If All 1's Are at Least K Places Away – LeetCode Today’s challenge was all about precision, pattern detection, and distance validation within a binary array. The goal? Ensure every 1 is properly spaced and respects the minimum distance k. ✨ Approach: I iterated through the array, tracked the position of each 1, and checked the gap before encountering the next one. A simple but effective two-pointer style logic! 📊 Complexity Analysis: ⏱ Time Complexity: O(n) — single pass through the array 💾 Space Complexity: O(1) — constant extra memory 🚀 Performance: ✔ Runtime: 1 ms (Beats 99.71%) ✔ Memory: 65.68 MB 🔑 Key Insight: Even a straightforward problem can sharpen your ability to detect patterns and handle constraints efficiently. Small details—like distances between bits—can make or break logic. #LeetCode #DSA #CodingChallenge #100DaysOfCode #ProblemSolving #BinaryArray #Algorithms #TechJourney #CodeEveryday #JavaCoding
To view or add a comment, sign in
-
-
⚡ Day 9 of #100 Days Of DSA Challenge Today’s focus: Remove Outermost Parentheses | Reverse Polish Notation 🔹 LeetCode 1021 – Remove Outermost Parentheses Keep a counter for open and close parentheses. Add characters to the result only when depth > 0. Avoid using a stack by tracking balance of brackets directly. Time: O(n) | Space: O(1) 🔹 LeetCode 150 – Evaluate Reverse Polish Notation (Postfix Expression) Use a stack to evaluate expressions. For each token: If number → push to stack If operator → pop two numbers, perform operation, push result back Final stack top gives the answer. Time: O(n) | Space: O(n) 💡 Key takeaway: Stack logic can often be optimized or even replaced with simple counters and pointer techniques when operations follow predictable patterns. #DSA #Stack #Queue #LeetCode #CodingChallenge #100DaysOfCode #100DaysOfDSAChallenge
To view or add a comment, sign in
-
🎯 Day 9 of my #120DaysCodingChallenge 💡 Problem: Palindrome Number (LeetCode – Easy) Given an integer x, the task is to determine whether it reads the same backward as forward. For example: 121 → ✅ Palindrome -121 → ❌ Not a palindrome 10 → ❌ Not a palindrome 🧠 My Approach: I solved this problem using the string conversion method in C for clarity and simplicity. 🔹 First, I handled negative numbers since they can’t be palindromes. 🔹 Then, I converted the integer into a string using sprintf(). 🔹 Using two-pointer logic, I compared characters from the start and end of the string — moving inward until all pairs matched. 🔹 If all corresponding digits matched, the number was a palindrome. ⚙️ Time Complexity: O(n) ⚙️ Space Complexity: O(n) 💬 Takeaway: This problem reinforced how string manipulation and two-pointer logic can simplify palindrome checks. In future, I’ll explore the mathematical approach (without converting to string) for better space efficiency. #Day9 #CodingChallenge #LeetCode #CProgramming #PalindromeNumber #100DaysOfCode #LearningInPublic #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 110 of Code — 350 DSA Problems Solved The past 10 days have been a full-circle revision sprint — refining logic, spotting patterns faster, and strengthening problem intuition. Here’s what I focused on 👇 🔹 Prefix Sum & Hashing Efficient range queries, subarray sums, and frequency lookups. 🔹 Arrays & Matrices Core manipulation, traversals, and 2D problem-solving patterns. 🔹 Two Pointers Opposite-end and fast–slow techniques for array and linked list problems. 🔹 Sliding Window Fixed and variable-size windows for substring/subarray optimizations. 🔹 Stacks Monotonic stacks, parentheses validation, and expression evaluation. 💡 Key Takeaway: Revisiting these classic patterns made me realize — problem-solving isn’t about memorizing solutions; it’s about recognizing structures and building from fundamentals. 350 questions done. Clarity stronger. Logic sharper. Momentum building. #Day100 #DSA #ProblemSolving #CodingJourney #LeetCode #100DaysOfCode #TechStudent
To view or add a comment, sign in
-
-
🚀 Day 11 of #100DaysOfLeetCode: Remove Element Continuing my journey with "DSA with edSlash – 100 Days of LeetCode"! Today's problem focused on in-place array manipulation, a fundamental skill for efficient memory usage and algorithm optimization. ✅ Problem Solved: Remove Element Task: Remove all occurrences of a given value from an array in-place, returning the count of remaining elements. 💡 Key Insight: This problem demonstrates efficient two-pointer technique: Two-Pointer Approach: Use one pointer to iterate through the array and another to track the position for non-target elements In-Place Modification: Overwrite target elements as we find valid elements, eliminating need for extra space Optimal Efficiency: Achieves O(n) time complexity with O(1) space complexity 🔍 Learning Highlight: Today reinforced the power of the two-pointer technique for in-place array modifications. This pattern is incredibly versatile and appears in many array manipulation problems. The problem also emphasized the importance of understanding what "in-place" truly means - modifying the existing data structure without allocating new memory. This challenge taught me how to think about array indices as separate from the data they contain, a crucial mindset for solving many low-level optimization problems! #LeetCode #Arrays #TwoPointers #Algorithms #ProblemSolving #SoftwareEngineering #DataStructures #InPlace #Edslash #100DaysOfCode #ComputerScience
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