🎯 Day 83 of #100DaysOfCode 🔹 Problem: Count the Digits That Divide a Number – LeetCode ✨ Approach: A simple yet elegant digit-based problem! I extracted each digit of the number using modulo and division, then checked whether the digit cleanly divides the original number. Every valid digit increases the count — a perfect use-case for number breakdown and modular arithmetic. 🔢⚡ 📊 Complexity Analysis: ⏱ Time Complexity: O(d) — where d is the number of digits 💾 Space Complexity: O(1) — no extra data structures used ✅ Runtime: 0 ms (Beats 100% 🚀) ✅ Memory: 42.29 MB 🔑 Key Insight: Even basic problems sharpen precision — breaking numbers digit-by-digit reinforces strong logical thinking and clean coding habits. Sometimes the simplest loops teach the most. ✨ #LeetCode #100DaysOfCode #DSA #NumberTheory #ModularArithmetic #CleanCode #EfficientCoding #LogicBuilding #TechJourney #ProgrammingChallenge #CodingDaily
Counting Dividing Digits in #100DaysOfCode with LeetCode
More Relevant Posts
-
🔢 Day 69 of #100DaysOfCode 🔢 🔹 Problem: Maximum Count of Positive and Negative Integers – LeetCode ✨ Approach: A simple yet powerful one-pass solution! Iterated through the array, counting positives and negatives separately — and returned whichever count was greater. Clean, direct, and efficient. ⚡ 📊 Complexity Analysis: Time Complexity: O(n) — single traversal of the array Space Complexity: O(1) — no extra data structures used ✅ Runtime: 1 ms (Beats 12.27%) ✅ Memory: 46.89 MB 🔑 Key Insight: Sometimes, simplicity wins — clarity in logic often outperforms complex tricks. Counting right leads to coding right! 💡 #LeetCode #100DaysOfCode #ProblemSolving #DSA #Array #AlgorithmDesign #LogicBuilding #CodeJourney #ProgrammingChallenge #CodingDaily #Efficiency
To view or add a comment, sign in
-
-
LeetCode 217: Contains duplicate ⁇ Suppose you have a list of numbers, and you want to know if any number appears more than once. It’s like making sure everyone in class has a unique roll number! Approach 1: Set - Go through each number. - If it’s not in your set, add it. - If you ever see a number already in your set, you’ve got a duplicate! Approach 2: Hash Table (Counter) - Use a Counter to count how often each number appears in the list. - If any number appears more than once, return True (there’s a duplicate). Complexity: - Time Complexity: O(n) — One pass through all numbers. - Space Complexity: O(n) — Storing seen numbers or counts. Both approaches are fast and effective for catching duplicates quickly! Let’s check our numbers and make sure everyone’s unique! Check out the problem here: https://lnkd.in/g-JgRTEn Keep going, keep revising, and keep building confidence! 💪🔥 #DSA #Coding #ProblemSolving #Learning
To view or add a comment, sign in
-
🌟 Day 93 of My LeetCode Journey — Problem 686: Repeated String Match 💡 Problem Insight: Today’s problem explored how many times string A must be repeated so that string B becomes a substring of it. It’s a fun mix of string repetition and pattern matching — testing both logic and edge-case awareness. 🧠 Concept Highlight: The core idea is to keep repeating A until it’s at least as long as B, then check if B exists within it (or one more repetition). This problem reinforces concepts of string concatenation, searching, and boundary conditions in text processing. 💪 Key Takeaway: Sometimes, solutions aren’t about complexity but about knowing when to stop repeating — in both coding and persistence! ✨ Daily Reflection: Simple problems like these highlight the beauty of algorithmic reasoning — transforming trial-and-error into structured logic. #Day93 #LeetCode #100DaysOfCode #StringMatching #ProblemSolving #DSA #CodingJourney #LearnByDoing #SoftwareEngineering #Persistence
To view or add a comment, sign in
-
-
🧠 𝐔𝐧𝐝𝐞𝐫𝐬𝐭𝐚𝐧𝐝𝐢𝐧𝐠 𝐈𝐧𝐭𝐞𝐠𝐞𝐫 𝐎𝐯𝐞𝐫𝐟𝐥𝐨𝐰 𝐢𝐧 𝐂 I learned about integer overflow in C in theory, but now I’m experiencing it on a deeper level as I experiment with values that exceed the limits of short. In C, a short variable usually stores signed 16-bit integers. That means it can only represent values within a specific range. If you try to store something outside that range, it overflows. When a number gets too big to fit in memory, it “wraps around” and starts again from the lowest value, following how two’s complement works internally. So if you assign a value just beyond the maximum that a short can hold, it becomes a negative number instead of a larger positive one. This happens because of how binary arithmetic works at the bit level: ➢ The most significant bit (the highest-order bit) acts as the sign bit, and once that bit flips, the value is interpreted as negative. 𝐊𝐞𝐲 𝐭𝐚𝐤𝐞𝐚𝐰𝐚𝐲: ➢ Know the size and limits of each integer type you’re using. ➢ Use larger types (int, long, or long long) when your values might exceed the range. ➢ Consider fixed-width types like int16_t or int32_t from <stdint.h> for consistent behavior across platforms. Integer overflow isn’t just a classroom concept, it can cause real bugs and even security issues in production code if you’re not careful. #CProgramming #SoftwareEngineering #SystemsProgramming #CodingTips #ComputerScience #JuniorDeveloper #LearningInPublic
To view or add a comment, sign in
-
-
🎯 LeetCode Daily – Triangle (Day 113) Today’s problem deepened my understanding of Dynamic Programming on Triangular Grids, focusing on minimizing path sums efficiently. ✅ My Approach: 🔹 Problem – Triangle: • The goal was to find the minimum path sum from the top to the bottom of a triangle array. • Used Memoization (Top-Down DP) to recursively explore all paths while storing intermediate results to avoid redundant computations. • Implemented Tabulation (Bottom-Up DP) to build the solution iteratively starting from the last row and moving upward, computing the minimum path for each position using values from the row below. 🧠 Key Insight: This problem beautifully demonstrates the power of Dynamic Programming in optimizing recursive solutions. By transitioning from memoization to tabulation, the problem transforms from exponential recursion to an elegant linear-time solution. Recognizing overlapping subproblems and optimal substructure patterns is key to mastering DP on grids and triangles. 📊 Time Complexity: O(N²) 📦 Space Complexity: O(N²) #LeetCode #DSA #DynamicProgramming #ProblemSolving #DailyCoding #LearningInPublic #Day113
To view or add a comment, sign in
-
-
🚀 LeetCode Daily Challenge Complete! Just solved "Final Value of Variable After Performing Operations" - a simple yet elegant problem that teaches the value of finding shortcuts in pattern matching! 💡 Solution Approach: ✅ Iterate through all operation strings ✅ Check middle character (index 1) ✅ If '-': decrement, if '+': increment ✅ Return final value The key insight: Instead of comparing full strings ("--X", "X--", "++X", "X++"), we can observe that ALL operations have the operator in the middle position! By checking just op[1], we instantly know whether to increment or decrement. Pattern recognition: "--X" and "X--" both have '-' at index 1 → decrement "++X" and "X++" both have '+' at index 1 → increment This single-character check is more efficient than string comparisons! Time Complexity: O(n) | Space Complexity: O(1) #LeetCode #StringParsing #CPlusPlus #Algorithms #SoftwareEngineering #ProblemSolving #CleanCode #PatternRecognition
To view or add a comment, sign in
-
🚀 Day 7 of #120DaysOfCode Challenge 💡 Problem: Reverse Integer (LeetCode #7 | Medium) 📄 Problem Statement: Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes it to go outside the signed 32-bit integer range [-2³¹, 2³¹ - 1], then return 0. 🧩 My Approach: Extract the last digit of x using % 10. Build the reversed number step by step using rev = rev * 10 + digit. Carefully check for overflow before multiplying or adding — using INT_MAX and INT_MIN limits to ensure the reversed number stays valid. If overflow is detected, return 0. 🔍 Key Learnings: How to handle integer overflow without using 64-bit variables. Importance of edge case testing and boundary conditions. Reinforced understanding of modulus (%) and integer division (/) operations. 🔥 Progress: Day 7 / 120 📚 Language: C 🏁 Problem Solved: Reverse Integer (LeetCode #7) Every problem is a small step toward stronger logic and cleaner code! 💪 #100DaysOfCode #120DaysOfCode #CodingChallenge #LeetCode #CProgramming #ProblemSolving #LearnEveryday #BuildInPublic
To view or add a comment, sign in
-
-
✅ Day 4 of 50 Days Coding Challenge Problem: Product of Array Except Self Difficulty: Medium 🔍 What’s the challenge? Given an integer array nums, return an array answer such that answer[i] equals the product of all elements in nums except nums[i]. Constraints: Must run in O(n) time No division operation allowed 💡 My Approach: I used a two-pass prefix-suffix multiplication technique because: Division is not allowed, so we can’t simply compute the total product and divide. We need an efficient solution in O(n) without extra space (apart from the output array). Steps: 1. Initialize answer with 1s. 2. Traverse from left to right, storing cumulative product of elements before i (prefix). 3. Traverse from right to left, multiplying cumulative product of elements after i (suffix). 4. This way, each answer[i] = (product of all elements to the left) × (product of all elements to the right). ✅ Time Complexity: O(n) ✅ Space Complexity: O(1) (excluding output array) 📌 Why i used this method? 1. It avoids division, which is a constraint. 2. It’s memory-efficient and scales well for large arrays. 3. It’s a clean and intuitive approach using prefix and suffix products. When division is restricted, prefix-suffix multiplication is a powerful pattern for array problems. #LeetCode #CodingChallenge #CSharp #ProblemSolving #Day4 #DataStructuresAndAlgorithms #50DaysCodingchallenge
To view or add a comment, sign in
-
-
Two Pointers Pattern: What I Learned While Practicing DSA Today Today I focused on understanding the Two Pointers pattern — and it immediately helped me see how so many array and string problems can be solved more efficiently than I thought before. At first, I often used nested loops for these kinds of problems, which made my code long and slow. But when I understood how the two-pointer idea works, it suddenly felt clean, simple, and logical. The beauty of this pattern is that you don’t need to brute-force every possibility — you just move two pointers intelligently until you reach the answer. ✅ My Key Takeaway Two Pointers is all about scanning a structure from both ends or at different speeds to avoid extra work. You either move both pointers toward each other or one pointer ahead while the other follows behind. Once you get this movement logic right, many problems that look complicated become linear-time solutions. ✅ Problems I Practiced Today 🔹 Two Sum II – Input Array Is Sorted (LeetCode 167) https://lnkd.in/dzUTArdH — Moved left and right pointers based on the sum comparison, no nested loops needed. 🔹 Container With Most Water (LeetCode 11) https://lnkd.in/diuufDsD — Used both ends of the array and kept moving the smaller height pointer. Elegant and fast. 🔹 Remove Duplicates from Sorted Array (LeetCode 26) https://lnkd.in/dsM3qZuG — One pointer tracks the unique position, the other scans ahead. Simple but very efficient. Practicing these gave me a solid feel for how pointer coordination reduces both time and code complexity. #LearningInPublic #DSA #CodingPatterns #CodingJourney #ProblemSolving #LeetCode #SoftwareEngineering #DeveloperMindset #SDEJourney #CleanCode #TechCommunity
To view or add a comment, sign in
-
🚀 How I Solved LeetCode’s Word Search Problem Without DFS or Recursion When I came across Word Search (LeetCode 79), I noticed that almost every solution used DFS and backtracking. But I wanted to solve it my own way — using index tracking and adjacency logic instead of recursion. My intuition was simple: If a word exists in the grid, every next letter must lie right next to the previous one — either up, down, left, or right. That means their coordinate difference should satisfy: abs(x1 - x2) + abs(y1 - y2) == 1. This small observation became the foundation of my entire approach. 💡 My Thought Process 1️⃣ I mapped every letter in the grid to its coordinates. 2️⃣ I started from all positions of the first letter in the word. 3️⃣ For every next letter, I checked which positions are adjacent and not already used. 4️⃣ I extended paths step by step — no recursion, only iteration. 5️⃣ If any path reached the last letter → the word exists. ⚙️ My Implementation I used a BFS-style iterative search, where each state holds: the current cell (x, y) the current index in the word and a bitmask representing already-used cells. This replaced recursion and heavy visited[][][] arrays with a compact integer mask. Each move just extended to adjacent cells if the next character matched. It handled tricky cases like "ABCB" perfectly → returned false, which even some DFS implementations fail on. ✅ Why It Worked ✔️ No recursion = no stack overflow. ✔️ Bitmask = minimal memory use. ✔️ Adjacency rule = exactly matches grid movement. ✔️ Iterative BFS = simple, efficient, and logical. 🎯 What I Learned You don’t always need to follow the standard algorithms. Sometimes, just trusting your intuition and building around your idea leads to something even better. This problem taught me that creativity and logic go hand in hand. And when you believe in your approach — it truly works. 💪 #Coding #LeetCode #ProblemSolving #Cplusplus #Innovation #DSA #Learning #DeveloperJourney
To view or add a comment, sign in
-
Explore related topics
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