🚀 Day 46 of #100DaysOfCode Solved LeetCode Problem #1390 – Four Divisors 🔢 This problem focused on identifying numbers that have exactly four divisors and summing those divisors efficiently. The key challenge was optimizing divisor counting to avoid unnecessary computations. Key Learnings: -> Iterated divisors only up to √n for efficiency -> Carefully tracked divisor count and sum simultaneously -> Pruned early when divisor count exceeded four -> Reinforced number theory basics with practical optimization Language Used: Java -> Runtime: 9 ms (Beats 97.47%) -> Memory: 46.32 MB Small constraints, clean logic, and efficient pruning make a big difference 🚀 #LeetCode #Java #ProblemSolving #NumberTheory #100DaysOfCode #DSA
Java LeetCode Problem 1390 Four Divisors Optimization
More Relevant Posts
-
LeetCode POTD #3010 - Minimum Cost (1 February 2026) Problem: Pick exactly 3 elements such that the cost is minimum, with nums[0] being mandatory. Approach: Fix nums[0]. From the remaining array, find the smallest and second smallest elements. Intuition: Since nums[0] must be included, the optimal solution is to pair it with the two minimum values from the rest. Implementation: Single pass to track firstMin and secondMin. No sorting needed. Time Complexity: O(n) Space Complexity: O(1) #LeetCode #POTD #DSA #Java #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 63 of #100DaysOfCode Solved LeetCode Problem #3315 – Construct the Minimum Bitwise Array II 🧩 This problem was a great follow-up to Part I, pushing deeper into bitwise reasoning to construct the minimum valid array under stricter constraints. The challenge was all about identifying the right bit mask to preserve required bits while minimizing the result. Key Learnings: -> Applied advanced bit masking techniques -> Understood how (n & (n + 1)) patterns help derive minimal values Handled special edge cases efficiently -> Reinforced confidence in low-level bit manipulation logic Language Used: Java -> Runtime: 1 ms (Beats 100.00%) -> Memory: 47.04 MB (Beats 16.67%) Consistency and clarity—one bit at a time 🚀 #LeetCode #Java #BitManipulation #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 67 of #100DaysOfCode Solved LeetCode Problem #1984 – Minimum Difference Between Highest and Lowest of K Scores ✅ This problem focused on minimizing the score gap by smartly selecting k elements after sorting the array. A perfect example of how sorting + sliding window logic can turn a problem simple and efficient. Key Learnings: -> Sorting simplifies comparisons -> Sliding window to evaluate consecutive groups of size k -> Avoid brute force by leveraging order -> Small observations lead to clean solutions Language Used: Java -> Runtime: 8 ms (Beats 89.22%) -> Memory: 47.09 MB (Beats 25.34%) Consistency > Intensity 💪 On to the next challenge 🚀 #LeetCode #Java #ProblemSolving #Algorithms #Sorting #SlidingWindow #100DaysOfCode
To view or add a comment, sign in
-
-
🔹 Day 97 – LeetCode Practice 📌 Problem: Divide Array Into Equal Pairs (LeetCode #2206) 📊 Difficulty: Easy 🧠 Problem Overview: You’re given an integer array containing 2n elements. The goal is to check whether the array can be divided into n pairs such that: Every element is used exactly once Both elements in each pair are equal ✅ Approach Used: Sorted the array to bring identical elements together. Traversed the array while counting occurrences of each number. Verified that every number appears an even number of times, ensuring valid pairs. 📈 Submission Results: Status: Accepted ✅ Runtime: 8 ms Memory Usage: 46.94 MB 💡 Reflection: This problem is a great reminder that sorting can simplify pairing logic significantly. Once the array is ordered, validating pairs becomes straightforward and efficient. #LeetCode #ProblemSolving #Arrays #Java #DSA #CodingPractice #Consistency
To view or add a comment, sign in
-
-
Day 2/30 – LeetCode #121 (Best Time to Buy and Sell Stock) | Java Solved this by first considering a brute-force approach that checks all buy–sell pairs, which leads to O(n²) time complexity and isn’t scalable. The challenge was figuring out how to optimize without overcomplicating the logic. The key insight was to track the minimum price so far while iterating through the array once. At each step, computing the difference between the current price and the minimum price allowed me to update the maximum profit efficiently. This reduces the solution to O(n) time and O(1) space. This problem reinforced how maintaining state with simple variables in Java can often replace nested loops and lead to cleaner, more efficient solutions. #LeetCode #Java #DSA #Arrays #Greedy #Consistency #LearningInPublic
To view or add a comment, sign in
-
-
🔹 Day 96 – LeetCode Practice 📌 Problem: First Missing Positive (LeetCode #41) 📊 Difficulty: Hard 🧠 Problem Overview: Given an unsorted integer array, the task is to find the smallest positive integer that is missing from the array. The challenge lies in solving it efficiently with strict constraints on time and space. ✅ Approach Used: Stored all values from the array for quick lookup. Iterated from the smallest possible positive integer to identify the first missing value. Returned the earliest number that was not present. 📈 Submission Results: Status: Accepted ✅ Runtime: 14 ms Memory Usage: 93.44 MB 💡 Reflection: This problem highlights the importance of understanding constraints clearly. While multiple approaches exist, optimizing time and space is the key learning takeaway from this question. #LeetCode #DSA #ProblemSolving #Arrays #Java #CodingJourney #Consistency
To view or add a comment, sign in
-
-
Day 27 – DSA / LeetCode Challenge 🚀 Today’s problem was #3794 Reverse String Prefix, and I solved it using an optimized in-place approach in Java. 🧠 Key takeaway This problem reinforced an important optimization mindset: Even when a solution works, revisiting it can lead to better performance and cleaner logic. By operating directly on a character array, we can avoid unnecessary string creation. ⚙️ Approach used Convert the string into a character array Reverse only the first k characters using two-pointer swapping Keep the remaining characters unchanged Convert the array back to a string This was a great example of how small implementation changes can significantly improve runtime and memory, while keeping the code simple and interview-ready. Practicing consistently on LeetCode and refining solutions every day 💪 On to Day 28 🚀 #Day27 #DSA #LeetCode #Java #ProblemSolving #StringManipulation #TwoPointers #CodingJourney
To view or add a comment, sign in
-
-
Day9 - LeetCode Journey Solved LeetCode 1572: Matrix Diagonal Sum in Java ✅ This problem was a nice mix of simplicity and attention to detail. The main idea was to traverse the matrix once and add both the primary and secondary diagonal elements without double counting the middle element when the matrix size is odd. It reminded me how important small conditions are in logic-based problems. One extra check can make the difference between a correct and an incorrect solution. Clean traversal and clear understanding of matrix indexing were the key here. Key takeaways: • Understanding matrix traversal properly • Handling edge cases like overlapping diagonals • Writing efficient and readable code ✅ Accepted with 100% runtime performance ✅ Simple yet strong problem for building fundamentals Staying consistent with DSA practice and improving step by step. Every small problem adds to better clarity and confidence 💪 #LeetCode #DSA #Java #Matrices #Algorithms #ProblemSolving #LeetCode1572 #OptimalSolution #CodingPractice #InterviewPreparation #Consistency
To view or add a comment, sign in
-
-
🚀 Day 77 of #100DaysOfLeetCode 📌 Problem: 1877. Minimize Maximum Pair Sum in Array 📊 Difficulty: Medium 🧠 Key Insight: To minimize the maximum pair sum, pair the smallest element with the largest, the second smallest with the second largest, and so on. This balances the sums and avoids any single pair becoming too large. ⚙️ Approach: Sort the array Use two pointers: i starting from the beginning j starting from the end Pair nums[i] + nums[j] and track the maximum sum Move both pointers inward until all pairs are formed ⏱️ Complexity: Time: O(n log n) Space: O(1) #LeetCode #Java #ProblemSolving #CodingChallenge #100DaysOfCode #DSA #LearningEveryday
To view or add a comment, sign in
-
-
🔹 Day 85 – #100DaysOfLeetCode Problem: 3010. Divide an Array Into Subarrays With Minimum Cost I Difficulty: Easy Key Insight: The cost of a subarray depends only on its first element. Since the first subarray always starts at index 0, the problem reduces to selecting the two smallest possible starting elements from the remaining array. Approach: Fix the first subarray cost as nums[0] Find the smallest and second smallest values in nums[1…n-1] Add them to get the minimum total cost Time Complexity: O(n) Space Complexity: O(1) #LeetCode #Java #ProblemSolving #CodingChallenge #100DaysOfCode #DSA #LearningEveryday
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
👍