🚀 Day 73 — LeetCode Practice 🚀 Today’s problem: Find the Distance Value Between Two Arrays 💡 What I learned today: • Practiced nested loops and comparison logic • Strengthened understanding of absolute difference using Math.abs() • Learned how to use a boolean flag to optimize checking conditions • Improved handling of edge cases and conditions 🧠 Key idea: For each element in arr1, check all elements in arr2 → if no element satisfies the condition |arr1[i] - arr2[j]| ≤ d → then count it. ✨ Step by step, logic is becoming clearer and faster. #Day73 #LeetCode #Java #ProblemSolving #DSA #CodingJourney #Consistency
LeetCode Practice: Finding Distance Between Arrays
More Relevant Posts
-
Day 61 of 100 Days of LeetCode 🚀 Solved First Unique Character in a String (LeetCode 387) today. 🔍 Key Learnings: Used frequency array to count character occurrences efficiently Importance of two-pass approach: Count frequencies Identify first unique character Reinforced concept of optimizing from brute force (O(n²)) to linear time (O(n)) ⚡ Complexity: Time: O(n) Space: O(1) (fixed 26 characters) 💡 Small problem, but a good reminder that clean logic and simplicity beat overcomplication. #Day61 #100DaysOfCode #LeetCode #DSA #Java #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 88 — LeetCode Practice 🚀 Today’s focus was on factorization and optimization techniques. ✅ Problem solved today: 🔹 Construct the Rectangle 💡 Key learnings from today: • Understood how to find factors of a number efficiently • Learned why starting from √area gives the closest dimensions • Strengthened concepts of minimizing difference between two values • Explored how mathematical logic can optimize brute-force solutions • Improved understanding of time complexity reduction 🧠 Approach used: Started checking from √area and moved downwards to find the first factor pair. This ensures length ≥ width and minimum difference. ⚡ Time Complexity: O(√n) 📦 Space Complexity: O(1) 📈 Progress: Getting better at optimizing solutions and thinking mathematically! #Day88 #LeetCode #DSA #Java #CodingPractice #ProblemSolving #Consistency #TechGrowth
To view or add a comment, sign in
-
-
🚀 Day 18 of #100DaysOfCode Solved LeetCode 334 – Increasing Triplet Subsequence 📈 Today’s problem was all about optimizing from brute force to a smart greedy approach. Instead of checking all triplets, I tracked the smallest and second smallest values while iterating once through the array. 💡 Key Insight: If we find a number greater than both first and second, an increasing triplet exists! 🔍 What I learned: Greedy approach can reduce time complexity drastically Maintaining two variables is enough to detect a triplet Writing clean and efficient O(n) solutions ⚡ Performance: Runtime: 2 ms (Beats 99.28%) Memory: Solid optimization #DSAwithEdSlash #LeetCode #Java #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 17 of LeetCode Problem Solving Solved today’s problem — LeetCode #13: Roman to Integer 💻🔥 ✅ Approach: Traversal + Mapping ⚡ Time Complexity: O(n) 📊 Space Complexity: O(1) The task was to convert a Roman numeral string into an integer. 👉 I mapped each Roman symbol to its value and traversed the string to calculate the result. 💡 Key Idea: If current value < next value → subtract it Otherwise → add it 👉 Core Logic: Convert each character to its numeric value Compare with next character Apply addition or subtraction accordingly 💡 Key Learning: Understanding patterns (like subtraction rule in Roman numbers) helps simplify the problem logic. Consistency is the key — improving step by step 🚀 #Day17 #LeetCode #DSA #Java #CodingJourney #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 5 of #LeetCode Challenge 🔍 Problem: Minimum Distance Between Three Equal Elements I 💡 Approach: Used a brute-force approach with three nested loops to check all possible triplets (i, j, k). Checked if nums[i] == nums[j] == nums[k] Calculated distance using: |i - j| + |j - k| + |k - i| Tracked the minimum distance using Math.min() 🧠 Key Concept: Understanding triplet traversal and applying absolute distance formula. 🔥 #Day5 #LeetCode #Java #DSA #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 87 — LeetCode Practice 🚀 Today’s focus was on ranking logic and nested iteration concepts. ✅ Problem solved today: 🔹 Relative Ranks 💡 Key learnings from today: • Understood how to determine ranks by comparing each element with others • Learned how counting higher scores helps assign positions • Strengthened concepts of nested loops and conditional logic • Explored how to map rankings into strings like Gold Medal, Silver Medal, Bronze Medal • Improved thinking on converting numeric logic into meaningful output 🧠 Approach used: Used a brute-force method where for each score, I counted how many scores are greater than it to determine its rank. ⚡ Time Complexity: O(n²) 📦 Space Complexity: O(n) 📈 Progress: Staying consistent and improving problem-solving step by step! #Day87 #LeetCode #DSA #Java #CodingJourney #Consistency #ProblemSolving #TechGrowth
To view or add a comment, sign in
-
-
🚀 Day 14 of LeetCode Problem Solving Solved today’s problem — LeetCode #34: Find First and Last Position of Element in Sorted Array 💻🔥 ✅ Approach: Binary Search (Twice) ⚡ Time Complexity: O(log n) 📊 Space Complexity: O(1) The task was to find the starting and ending position of a target element in a sorted array. 👉 Instead of linear search, I used Binary Search twice: One to find the first occurrence One to find the last occurrence 💡 Key Idea: Modify binary search slightly to keep searching even after finding the target. 👉 Core Logic: If target found → store index Continue searching left (for first position) Continue searching right (for last position) 💡 Key Learning: Binary Search is not just for finding elements — it can be modified to solve many variations efficiently. Consistency is the key — getting better every day 🚀 #Day14 #LeetCode #DSA #Java #CodingJourney #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Starting with #1/100DaysOfCode 💪 Sharing something from LeetCode today 🚀 Recently solved 1572. Matrix Diagonal Sum, and it had a small twist that can confuse many people. 💡 Approach : Traverse the matrix using loops Add elements where: i == j → Primary diagonal i + j == n - 1 → Secondary diagonal ⚠️ Common Confusion: Most people think that for this matrix: [[1,2,3], [4,5,6], [7,8,9]] the element 5 will be counted twice ❌ But it’s NOT counted twice ✅ Because we use: if(i == j) else if(i + j == n - 1) So once the first condition is true, the else if will not run. That’s why the middle element is added only one time. Grateful to learn and grow with guidance from: RAVI KUMAR Coding Blocks Sunstone #LeetCode #CodingJourney #Java #ProblemSolving #Consistency #CodingBlocks #SUNSTONE
To view or add a comment, sign in
-
-
🚀 Day 72 — LeetCode Practice 🚀 Today’s problem: Sorting the Sentence 💡 What I learned today: • Practiced string manipulation and splitting techniques • Understood how to extract numbers from characters using ASCII logic • Learned to map words to correct positions using indexing • Improved attention to detail while handling edge cases 🧠 Key idea: Each word has a number at the end → use it to place the word in the correct position → then remove the number and rebuild the sentence. ✨ Consistency is slowly turning confusion into clarity. #Day72 #LeetCode #Java #ProblemSolving #DSA #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 Day 8 / 150 – LeetCode Challenge 📌 Problem: Plus One Today’s problem was simple but teaches an important concept — handling carry in arrays. 💡 Given a number represented as an array of digits, we need to add +1 and return the result. 🔑 Key Insight: - Start from the last digit - If digit < 9 → just add 1 and return - If digit == 9 → make it 0 and carry forward - If all digits are 9 → create a new array with leading ⚡ Time Complexity: O(n) ⚡ Space Complexity: O(1) (except edge case) Consistency > Motivation. 8 days done, 142 to go 💪 #LeetCode #CodingChallenge #DataStructures #Java #Consistency #100DaysOfCode #CodingThinker
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