🚀 Day 70/100 – DSA Challenge Consistency is turning into confidence 💯 Today’s problem focused on string comparison and optimization. 🔍 Problem: Given two arrays of strings — queries and dictionary — identify all query words that differ from any dictionary word by at most 2 characters. 🧠 Approach: Compare each query with every dictionary word Count character mismatches If mismatches ≤ 2 → include the query in the result Use early termination to optimize comparisons 💡 Key Learning: This problem reinforced the importance of efficient brute force, where small optimizations like early breaks can significantly improve performance. ⏱️ Time Complexity: O(Q × D × L) 📦 Space Complexity: O(1) (excluding output) Another milestone unlocked 🔓 — Day 70 done! On to Day 71 🚀 #100DaysOfCode #DSA #Java #ProblemSolving #CodingJourney #Consistency #KeepLearning
Day 70 DSA Challenge: String Comparison and Optimization
More Relevant Posts
-
Day 4 of my DSA consistency journey Solved a classic problem today: Group Anagrams At first glance, it looks simple but if you try brute force (comparing every string with every other), it quickly becomes inefficient. Key idea I used: If two strings are anagrams, their sorted form will be the same. So the approach was: Convert each string to a character array Sort it Use the sorted string as a key in a HashMap Group all original strings under the same key Complexity: Time: O(n * k log k) Learned that this can be further optimized using character frequency instead of sorting Biggest takeaway: It’s not about solving the problem it’s about choosing the right approach early instead of wasting time on brute force. Consistency matters more than intensity. Showing up daily and improving step by step. #DSA #Java #CodingJourney #Consistency #Learning
To view or add a comment, sign in
-
-
🚀 DSA Preparation 💪 Solved an interesting Array + Sliding Window problem on maximizing score. Instead of picking cards directly, learned to think in reverse by finding the minimum subarray to exclude 🔥 This approach helps in optimizing the solution efficiently 🚀 🧠 Problem 🔎 Maximum Points You Can Obtain from Cards Given an array cardPoints and an integer k, you can take cards from the beginning or end. 👉 You must take exactly k cards. 👉 Return the maximum score possible. Example Input: cardPoints = [1,2,3,4,5,6,1], k = 3 Output: 12 Input: cardPoints = [2,2,2], k = 2 Output: 4 Input: cardPoints = [9,7,7,9,7,7,9], k = 7 Output: 55 Improving DSA with better thinking and optimization 🚀 #DSA #LeetCode #SlidingWindow #Arrays #Java #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 70 of #100DaysOfCode Solved 107. Binary Tree Level Order Traversal II on LeetCode 🔗 🧠 Key Insight: This is just level order traversal (BFS) but: 👉 Return levels from bottom to top instead of top to bottom ⚙️ Approach (DFS with Level Tracking): 1️⃣ Start traversal with level = 0 2️⃣ For each node: 🔹 If level not present → insert new list at front 🔹 Add value at correct position: 👉 res.get(res.size() - 1 - level) 3️⃣ Recurse: 🔹 Left → level + 1 🔹 Right → level + 1 ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(n) #100DaysOfCode #LeetCode #DSA #BinaryTree #BFS #DFS #Java #InterviewPrep #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 47 of My Java DSA Journey Today I solved a classic and important problem: 🌧️ Trapping Rain Water 💡 Problem idea: Given an elevation map, calculate how much water can be trapped after raining. 🔍 Approach I used: • Precomputed two arrays: leftMax[i] → maximum height to the left rightMax[i] → maximum height to the right • For each index: Water stored = min(leftMax, rightMax) - height[i] ⚡ Key Learning: Water at any point depends on the shorter boundary around it. 🔥 What improved today: • Array precomputation • Understanding of boundary-based problems • Writing efficient O(n) solutions 🎯 Takeaway: Preprocessing data can simplify complex problems significantly. #Day47 #90DaysOfCoding #Java #DSA #Arrays#ProblemSolving
To view or add a comment, sign in
-
-
🚀 DSA Preparation 💪 Solved a basic yet important Array + Two Pointer problem. Focused on rearranging elements by grouping even and odd numbers efficiently. Great for improving in-place operations and partitioning logic 🔥 🧠 Problem 🔎 Sort Array By Parity Given an integer array nums, move all even integers to the beginning followed by all odd integers. 👉 Return any array that satisfies this condition. Example Input: nums = [3,1,2,4] Output: [2,4,3,1] Input: nums = [0] Output: [0] ⚡ Key Learning 📌 Use two pointers / partition approach 📌 Efficiently rearrange elements in one pass 📌 Time Complexity: O(n) → traverse the array once 📌 Space Complexity: O(1) → in-place rearrangement (no extra space) Improving DSA with strong fundamentals 🚀 #DSA #LeetCode #Arrays #TwoPointers #Java #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
Day 8/30 — DSA Challenge 🚀 Problem: Search a 2D Matrix II Topic: Matrix + Binary Search Pattern Difficulty: Medium Approach: Started from top-right corner of the matrix If current element == target → return true If current element < target → move down If current element > target → move left Mistake / Challenge: Initially tried applying binary search like previous problem (LeetCode 74) Realized matrix is not globally sorted, so that approach fails Fix: Used optimal “staircase search” approach Reduced time complexity efficiently Key Learning: Not all sorted matrices can be treated as 1D arrays Recognize pattern: row-wise + column-wise sorted → use pointer approach Time Taken: 45 minutes Consistency check ✅ See you on Day 9. GitHub Repo: https://lnkd.in/gHW9vKUf #DSA #LeetCode #Java #Matrix #BinarySearch #LearningInPublic
To view or add a comment, sign in
-
-
🖤 Day 46 of Solving DSA : Four Sum------> Check Array Length: First, check if the length of the input array is less than 4. If yes, return an empty array or list because we can't form a valid group of 4 elements. Sort the Array: Sort the array in ascending order. Sorting helps us manage duplicates and makes it easier to work with combinations. Find Unique Combinations: Use a loop to go through the array and look for groups of 4 numbers. While looping, skip any duplicates by using an if condition to check if the current number is the same as the previous one. Store Results: For each valid group of 4 numbers without duplicates, add it to the result list. Return the Result: After completing the loops, return the list of unique combinations. Complexity Time complexity:O(n3) Space complexity:O(k) #DSA #java #logicalThinking #100dayschalleng #consistency #leetcode #tuf #striverSheet
To view or add a comment, sign in
-
-
🔥 Day 139/360 – Learning Something Powerful Today 🚀 Most people miss this simple trick… But once you understand it, problems become much easier 👇 📌 Topic: Bit Manipulation 🧩 Problem: Single Number 📝 Problem Statement: Find the element that appears only once in an array where every other element appears twice. 🔍 Example: Input: [4, 1, 2, 1, 2] Output: 4 💡 Approach: XOR (Optimized ⚡) ✔ Step 1 – Initialize XOR = 0 ✔ Step 2 – XOR all elements in the array ✔ Step 3 – Return XOR (unique element remains) ⚡ Key Idea: Same numbers cancel out using XOR (a ^ a = 0), leaving only the unique number. ⏱ Complexity: Time → O(n) Space → O(1) 📚 What I Learned: Bit manipulation can replace extra data structures and make solutions more efficient. #DSA #Java #Coding #ProblemSolving #InterviewPrep #LeetCode #TechJourney #139DaysOfCode
To view or add a comment, sign in
-
-
Day 74 of #100DaysOfLeetCode 💻✅ Solved #162. Find Peak Element problem in Java. Approach: • Used Binary Search technique to efficiently find the peak element • Set two pointers, left at start and right at end of the array • Calculated mid index using safe mid formula • Compared nums[mid] with nums[mid + 1] to determine direction • If mid element is smaller, moved search space to right half • Otherwise, moved search space to left half including mid • Continued until left and right pointers converged • Final position (left == right) represents the peak index Performance: ✓ Runtime: 0 ms (Beats 100.00% submissions) 🚀 ✓ Memory: 44.32 MB (Beats 25.49% submissions) Key Learning: ✓ Strengthened understanding of Binary Search on unsorted arrays ✓ Learned how to apply divide-and-conquer beyond traditional searching ✓ Improved intuition for peak finding using neighbor comparison ✓ Practiced optimizing search space instead of linear scanning Learning one problem every single day 🚀 #Java #LeetCode #DSA #BinarySearch #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 47/60 - DSA Challenge Today’s problem focused on finding a Peak Element using an optimized approach! 💡 🔍 Key Insight: A peak element is one that is greater than its neighbors. Instead of checking every element, I used Binary Search to efficiently locate a peak. ⚡ Approach: Compare the middle element with its next element If the next element is greater, the peak lies on the right side Otherwise, the peak lies on the left side (including the current element) Continue narrowing the search space until the peak is found 📈 Time Complexity: O(log n) 📦 Space Complexity: O(1) 🔥 This problem reinforced how powerful pattern recognition can be—turning a simple idea into an optimized solution using binary search. #Day47 #DSA #BinarySearch #CodingJourney #Java #ProblemSolving #LeetCode #100DaysOfCode
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