🚀 Day 91/100 - Problem of the day :- Four Divisors. 🎯 Goal Solve the problem efficiently by identifying numbers with exactly four divisors and calculating their sum. 💡 Core Idea Iterate through each number, find divisors up to √n, count them smartly, and stop early once divisors exceed four. 📌 Key Takeaway Optimizing divisor checks with early termination significantly improves performance. 🧠 Space Complexity: O(1) ⏱️ Time Complexity: O(n · √k), where k is the maximum value in the array. #LeetCode #DSA #Java #ProblemSolving #CodingJourney #Algorithms #Efficiency #100DaysChallenge
Efficiently find numbers with 4 divisors and sum them
More Relevant Posts
-
🚀 Day 147 | Frequency Counting Across Multiple Strings Today’s problem was a clean exercise in comparing character frequencies across multiple inputs. 🧩 Problem Solved: 1002. Find Common Characters 🔍 Approach: • Initialized a frequency array using the first word. • For each subsequent word, counted character frequencies and kept the minimum count for each character. • Constructed the result by adding each character as many times as its final minimum frequency. ✨ Key Insight: Using minimum frequency across all strings ensures only truly common characters are included. 📚 Topics: Hashing · Strings · Frequency Counting 💻 Platform: LeetCode #LeetCode #DSA #ProblemSolving #DailyCoding #Strings #Hashing #Java #Consistency
To view or add a comment, sign in
-
-
🚀 Day 21 of #100DaysOfCode 🧩 Problem: Find Median of Two Sorted Arrays (LeetCode #4, Hard) 💡 Concept: Given two sorted arrays, the goal is to find the median of the combined dataset after merging both arrays. 🛠 Approach (Merge + Sort): 1️⃣ Create a new array to store elements from both input arrays. 2️⃣ Copy all elements from nums1 and nums2 into the new array. 3️⃣ Sort the merged array using Bubble Sort to maintain order. 4️⃣ Determine the median: If total length is even, return the average of the two middle elements. If odd, return the middle element directly. 🔥 Performance: ✅ Accepted on LeetCode ⚡ Runtime: 52 ms 💾 Memory: 48.81 MB 📊 Complexity: ⏱ Time: O((m + n)²) — due to bubble sort 💾 Space: O(m + n) — extra array used for merging #100DaysOfCode #LeetCode #DSA #Java #ProblemSolving #Consistency #LearningInPublic #CodingJourney
To view or add a comment, sign in
-
-
Solved “3Sum Closest” (LeetCode – Medium) using the Two Pointer approach. Problem Solved: 3Sum Closest Approach: • Sorted the array to enable efficient pointer movement • Fixed one element and used left & right pointers to evaluate possible sums • Updated the closest sum based on minimum absolute difference from the target Key Learnings: • How sorting simplifies multi-pointer problems • Using absolute difference to track optimal results • Applying two-pointer logic beyond exact matches This problem helped me improve my understanding of: • Array-based problem solving • Two-pointer optimization techniques • Writing clean and readable logic Staying consistent with DSA practice to strengthen problem-solving fundamentals #DSA #TwoPointers #LeetCode #ProblemSolving #LearningByDoing #Java #CodingPractice
To view or add a comment, sign in
-
-
Day 24: Simplicity in Strategy! 🎯 Problem 1877: Minimize Maximum Pair Sum in Array Sometimes a "Medium" problem reveals a very intuitive "Easy" solution once you find the right perspective. Today’s challenge was to pair elements such that the largest sum among all pairs is minimized. The key insight? To keep the sums balanced and low, you should pair the smallest available number with the largest available number. By sorting the array and using a two-pointer approach to pair the i-th element with the (n−1−i)-th element, the optimal solution emerged naturally. #LeetCode #Sorting #Java #CodingChallenge #ProblemSolving #Algorithms
To view or add a comment, sign in
-
-
🧠 Day 76 of #100DaysOfLeetCode 📌 Problem: Combination Sum II 📊 Difficulty: Medium 💡 Key Insight: Sorting the array helps handle duplicates. While backtracking, duplicates are skipped only in the “not pick” path to ensure unique combinations. 🛠️ Approach: Sort the candidates array Use backtracking to explore combinations Each number can be used once → move to index + 1 Skip duplicate elements to avoid repeated combinations ⏱️ Complexity: Time: O(2^n) Space: O(n) #LeetCode #Java #ProblemSolving #CodingChallenge #100DaysOfCode #DSA #LearningEveryday
To view or add a comment, sign in
-
-
🚀 LeetCode Problem Solved (2315 – Count Asterisks) Another day, another clean win. ✅ This one was all about attention to detail, not brute force. 🔹 Core Idea Track whether we’re inside or outside a pair of | |. Count * only when they are outside valid bar pairs. 🔹 Why this matters • Tests string traversal & state tracking • Reinforces conditional logic and edge-case handling • Shows how simple flags can replace complex parsing 🔹 Complexity ⏱ Time: O(n) 📦 Space: O(1) Clean logic. Linear scan. Zero overthinking. That’s how you ship reliable solutions under pressure. 💪 Consistency isn’t loud—but the results are. On to the next one. 🚀 #LeetCode #LeetCodeDaily #DSA #ProblemSolving #Java #JavaDeveloper #Algorithms #CodingInterview #InterviewPrep #SoftwareEngineering #ComputerScience #CompetitiveProgramming #DailyCoding #100DaysOfCode #DeveloperJourney #TechCareers
To view or add a comment, sign in
-
-
Day 39/100 – LeetCode Challenge ✅ Problem: #1984 Minimum Difference Between Highest and Lowest of K Scores Difficulty: Easy Language: Java Approach: Sorting + Sliding Window Time Complexity: O(n log n) Space Complexity: O(1) Key Insight: After sorting, the minimum range in k elements must come from consecutive elements in sorted order. Sliding window of size k finds the minimum difference between first and last element in window. Solution Brief: Sorted the array to bring close values together. Initialized answer with first k elements. Slided window across array, updating minimum difference. Finding minimal range in sorted array with sliding window #LeetCode #Day39 #100DaysOfCode #Sorting #SlidingWindow #Java #Algorithm #CodingChallenge #ProblemSolving #MinimumDifference #EasyProblem #Array #Optimization #DSA
To view or add a comment, sign in
-
-
🚀 Day 49 of #100DaysOfCode Today’s challenge was a clean and elegant Two Pointer problem — 🔢 LeetCode: Two Sum II – Input Array Is Sorted 📌 Problem Summary You’re given a sorted array of integers and a target value. Your task is to find two numbers such that their sum equals the target and return their 1-based indices. ⚠️ Constraint: The array is already sorted, which opens the door to an optimized approach. 🧠 My Approach: Two Pointers Instead of using a HashMap, I leveraged the sorted property: Start one pointer at the beginning Another at the end Calculate the sum: If sum is too small → move left pointer forward If sum is too large → move right pointer backward If equal → solution found 🎯 This avoids extra space and keeps the solution super efficient. ⚙️ Complexity Analysis ⏱ Time: O(n) 💾 Space: O(1) Minimal memory, maximum efficiency 💡 🔥 Key Learning Always look for hidden constraints (like sorted input!) Two Pointer technique can replace HashMaps in many cases Clean logic often beats complex code ✅ Solution accepted with excellent runtime & memory performance Another fundamental pattern locked in 🔐 On to Day 50 — halfway milestone loading… 🚀🔥 #100DaysOfCode #LeetCode #Java #TwoPointers #Arrays #ProblemSolving #DSA #CodingJourney
To view or add a comment, sign in
-
-
🔹 Day 91 – LeetCode Practice 📌 Problem: Three Consecutive Odds (LeetCode #1550) 📊 Difficulty: Easy 🧠 Problem Overview: Given an integer array, determine whether there are three consecutive odd numbers appearing next to each other. Return true if such a sequence exists; otherwise, return false. ✅ My Approach: Traversed the array while keeping track of consecutive odd numbers. Increased a counter whenever an odd number appeared and reset it when an even number was found. As soon as the counter reached three, the condition was satisfied. 📈 Complexity Analysis: Time Complexity: O(n) Space Complexity: O(1) 🚀 Submission Results: Status: Accepted ✅ Runtime: 0 ms (Beats 100%) 🚀 Memory: 44.18 MB (Beats 38.42%) 💡 Reflection: This problem highlights how a simple counter-based logic can efficiently solve pattern-detection tasks. Clean logic and early exits make solutions both fast and readable. #LeetCode #DSA #Java #ProblemSolving #CodingPractice #LearningJourney
To view or add a comment, sign in
-
-
🚀 Day47-#100DaysOfCode Today, I tackled a classic array problem: Finding the Third Maximum Number in an Array. 💡 Problem: Given an integer array, return the third distinct maximum number. If it doesn’t exist, return the maximum number. ✨ How it works: Sort the array in ascending order. Traverse backwards to count distinct numbers. Return the third distinct max if found. Otherwise, return the largest. 🔑 Key takeaway: Handling distinct elements separately ensures correctness even when duplicates exist. #Java #CodingChallenge #DataStructures #Algorithms #100DaysOfCode #LinkedInLearning
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