🚀 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
Optimizing Logic for Maximum Product in Array
More Relevant Posts
-
#Day360 of #1001DaysOfCode 📘 LeetCode Daily Challenge Problem: Search in a Binary Search Tree (LeetCode 700) 💡 Approach: Used the properties of a Binary Search Tree to efficiently search for a value. At each step: If the value is smaller, move to the left subtree If larger, move to the right subtree This reduces the search space at every step. ⏱ Time Complexity: O(h) 🧠 Space Complexity: O(h) Continuing daily consistency in problem solving 🚀 #DSA #Java #LeetCode #BinaryTree #ProblemSolving #Coding
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
-
-
🚀 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
-
-
#Day357 of #1001DaysOfCode LeetCode Daily Challenge Problem: Decode the Slanted Ciphertext (LeetCode 2075) 💡 Approach: The encoded string represents a matrix filled row-wise. I traversed the matrix diagonally (top-left to bottom-right) by converting 2D indices into a 1D string index. Finally, removed trailing spaces to get the correct decoded message. (*you can use inbuilt .stripTrailing() function as well) ⏱ Time Complexity: O(n) 🧠 Space Complexity: O(n) Staying consistent with daily problem solving 🚀 #DSA #Java #LeetCode #ProblemSolving #Coding
To view or add a comment, sign in
-
-
#Day373 of #1001DaysOfCode LeetCode Daily Challenge Problem: Words Within Two Edits of Dictionary (LeetCode 2452) Approach: For each query word, compared it with every word in the dictionary and counted character mismatches. If the difference was at most 2 characters, the word was added to the result. Used early stopping to optimize comparisons. ⏱ Time Complexity: O(Q × D × L) 🧠 Space Complexity: O(1) Improving efficiency with small optimizations #DSA #Java #LeetCode #ProblemSolving #Coding #Consistency
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 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
To view or add a comment, sign in
-
-
🚀 Day 28/100 – LeetCode Challenge Today’s problem: Intersection of Two Arrays (349) 📌 Problem Summary: Given two arrays, find their intersection such that each element in the result is unique. 💡 My Approach: Used HashSet to store elements of the first array Checked elements of the second array using contains() Stored common elements in another set to avoid duplicates Converted the result set into an array 🧠 What I learned today: Efficient use of HashSet for fast lookup (O(1)) How to handle duplicate elements easily Importance of choosing the right data structure Writing clean and optimized code instead of using nested loops 💻 Code Approach (Java): Used sets to ensure uniqueness and optimize performance 🚀 Consistency matters more than perfection 🔑 #Day28 #100DaysOfCode #LeetCode #DSA #Java #CodingJourney #PlacementPreparation
To view or add a comment, sign in
-
-
🚀 Day 52 of #100DaysOfLeetCode Solved: Daily Temperatures (Monotonic Stack) Today’s focus was on understanding how to optimize from a brute-force O(n²) approach to an efficient O(n) solution using a stack. Key takeaways: Learned how to identify “next greater element” patterns Understood how monotonic stacks help avoid redundant work Practiced writing clean and optimized code Consistency is starting to pay off. Onto the next one. #DSA #Java #CodingJourney #LeetCode #ProblemSolving
To view or add a comment, sign in
-
-
Day 101 - LeetCode Journey Solved LeetCode 856: Score of Parentheses ✅ Looks tricky at first, but turns out to be a neat pattern problem. Instead of using a stack, used depth tracking + bit manipulation to calculate score efficiently. Core idea: Every "()" contributes 2^depth So just track depth and add score at the right moment. Key learnings: • Understanding pattern inside parentheses • Using depth instead of extra space • Bit manipulation for optimization ⚡ • Clean O(n) solution without stack ✅ All test cases passed ⚡ O(n) time | O(1) space Simple logic, powerful result 💡 #LeetCode #DSA #Stack #BitManipulation #Java #CodingJourney #ProblemSolving #InterviewPrep
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