Day 83 of #100DaysOfCode Today’s problem: Ugly Number An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5. Approach: Instead of checking all factors, I kept dividing the number by 2, 3, and 5 repeatedly: If the number reduces to 1 → it’s ugly ✅ If something else remains → not ugly ❌ 🔍 Key Insight: Efficient problem-solving is often about reducing complexity, not increasing checks. 🧠 What I learned: How to simplify factor-based problems Importance of repeated division in optimization Writing clean and efficient logic ⚡ Example: 6 → 2 × 3 → Ugly ✅ 14 → includes 7 → Not Ugly ❌ Consistency is slowly building confidence 💪 On to Day 84! #DSA #Java #CodingJourney #ProblemSolving #LeetCode #100DaysOfCode
Ugly Number Problem Solving Strategy
More Relevant Posts
-
🚀 Day 27/100 Days of Code Challenge Today’s problem: Find Peak Element (Leetcode 162) 🔍 What I learned: How to find a peak element efficiently without scanning the entire array Using Binary Search to reduce time complexity from O(n) to O(log n) Understanding how the “slope” of elements helps decide the search direction 🧠 Key Idea: Instead of checking every element, compare the middle element with its neighbor: If nums[mid] < nums[mid + 1] → move right Else → move left ✅ Example: Input: [1, 2, 3, 1] Output: 2 (index of peak element 3) Consistency is key 🔑 — improving problem-solving skills one day at a time! 💪 #Day27 #100DaysOfCode #LeetCode #BinarySearch #DSA #Java #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 33 of #128DaysOfCode 🧩 Problem Insight: The goal was to check whether a given string can be formed by repeating one of its substrings multiple times. 💡 Key Learning: Instead of checking all possible substrings (which can be inefficient), I learned an elegant trick: By concatenating the string with itself and removing the first and last characters, we can determine if the original string exists within it. ⚡ This approach helped me: - Improve my understanding of string patterns - Learn a smart optimization technique - Avoid brute-force solutions 🛠️ Concepts Practiced: - String manipulation - Pattern recognition - Optimized problem-solving approach 📈 Every day I’m getting better at identifying patterns and writing cleaner, more efficient code. #Day33 #128DaysOfCode #Java #DSA #CodingJourney #ProblemSolving #LeetCode
To view or add a comment, sign in
-
-
Day 78 of #LeetCode 🚀 Solved: Number of Steps to Reduce a Number to Zero Today’s problem was simple but a great reminder of how important basic logic and loops are. 💡 Key Idea: If number is even → divide by 2 If odd → subtract 1 Repeat until it becomes 0 📌 Focus: Strengthening fundamentals Writing clean and efficient logic Consistency > Complexity 💯 Slowly building problem-solving mindset every day. #Day78 #CodingJourney #Java #DSA #LeetCode #Consistency #FutureDeveloper
To view or add a comment, sign in
-
-
#Day72 Of Problem Solving Solved today’s LeetCode Daily Challenge ✅. Problem: Check if Binary String Has at Most One Segment of Ones Sometimes, the simplest logic gives the best results. Instead of overthinking, I went with a clean approach—just checking if "01" exists in the string. If it does, that means more than one segment of 1’s… and that’s it! ✔️ All test cases passed ⚡ Runtime: 0 ms 📊 Beat 100% in performance This problem was a good reminder that not every solution needs complexity—clarity matters more. Consistency > Complexity 🚀 On to the next challenge! #LeetCode #DailyChallenge #Java #ProblemSolving #CodingJourney #100DaysOfCode #LinkedIn
To view or add a comment, sign in
-
-
🚀 Day 8 of #100DaysOfCode Solved: Maximum Product of Two Elements in an Array 💻 Today’s problem was all about optimizing logic and thinking smart instead of brute force. Instead of checking every pair, I focused on finding the two largest elements efficiently and used them to compute the result in a single pass 🔥 ✅ Time Complexity: O(n) ✅ Space Complexity: O(1) Small problems like these really sharpen problem-solving skills and reinforce the importance of clean, efficient code. Consistency is key — showing up every day, learning something new, and getting 1% better 💯 #DSA #Java #CodingJourney #LeetCode #ProblemSolving #Consistency #Day8#DSAwithEdSlash
To view or add a comment, sign in
-
-
🚀 Day 29/100 – #100DaysOfCode Today’s problem: Middle of the Linked List (LeetCode 876) 🎯 💡 What I learned: How to find the middle node efficiently using the two-pointer (slow & fast) approach Understanding why the fast pointer moves twice as fast as the slow pointer Handling both odd and even length linked lists Writing optimal code with O(n) time and O(1) space 🧠 Key Idea: Use two pointers: slow → moves 1 step at a time fast → moves 2 steps at a time 👉 When fast reaches the end, slow will be at the middle! 📊 Complexity: Time: O(n) Space: O(1) 📈 One step closer to mastering Linked Lists..... #Day29 #100DaysOfCode #LeetCode #LinkedList #DSA #Java #CodingJourney #ProblemSolving #TechSkills
To view or add a comment, sign in
-
-
🚀 Day 54 of my #100DaysOfCode Journey Today, I solved LeetCode – Sort Array By Parity II Problem Insight: Rearrange the array such that even-indexed positions have even numbers and odd-indexed positions have odd numbers. Approach: • Created a new result array of same size • Used two pointers: evenplace = 0 and oddplace = 1 • Traversed the array once • Placed even numbers at even indices and odd numbers at odd indices • Incremented pointers by 2 to maintain correct positions Time Complexity: O(n) | Space Complexity: O(n) Key Takeaway: Using two pointers for index placement makes the solution clean, efficient, and avoids unnecessary swaps. #DSA #Java #LeetCode #100DaysOfCode #CodingJourney
To view or add a comment, sign in
-
-
Today I solved: Longest Consecutive Sequence 💡 Key Takeaway: Sorting seems like the obvious approach, but it’s not the most optimal. By using a HashSet, we can reduce the time complexity and achieve an O(n) solution. 👉 Approach: - Store all elements in a Set - Start sequence only when the previous number is not present - Count the length of consecutive numbers 📊 Time Complexity: O(n) 🔍 What I learned: Sometimes the best solution comes from avoiding unnecessary work (like sorting) and thinking in terms of direct lookup using hashing. Optimizing the approach is as important as solving the problem 💪 #DSA #LeetCode #Java #CodingJourney #SoftwareEngineering
To view or add a comment, sign in
-
Day 31/50 🚀 — Reverse Vowels of a String (LeetCode 345) Today’s problem was a great reminder that sometimes the simplest approaches are the most efficient. 🔹 Used the two-pointer technique 🔹 Focused on in-place swapping 🔹 Optimized for both time (O(n)) and space (O(1)) Key takeaway: Instead of overthinking, break the problem into smaller checks—identify vowels, move pointers smartly, and swap only when needed. Clean and efficient 💡 Happy to see this solution performing well: ⚡ Runtime: 2 ms (faster than 99%+) 📦 Space: Decent optimization #Day31 #LeetCode #DSA #Java #CodingJourney #50DaysOfCode #ProblemSolving #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Day 28/100 – #100DaysOfCode Today’s problem: Reverse Linked List (LeetCode 206) 💡 What I learned: How to reverse a singly linked list using an iterative approach Managing pointers efficiently (prev, curr, next) Understanding how links change direction step by step 🧠 Key Idea: Instead of creating a new list, we reverse the links in-place: Store next node Reverse current pointer Move forward 📊 Complexity: Time: O(n) Space: O(1) Staying consistent, one problem at a time... #Day28 #100DaysOfCode #LeetCode #DSA #LinkedList #Java #CodingJourney #ProblemSolving #TechSkills
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