🚀 Day 24/100 — #100DaysOfLeetCode Another step forward in strengthening string problem-solving skills 💻🔥 ✅ Problem Solved: 🔹 LeetCode 28 — Find the Index of the First Occurrence in a String 💡 Concepts Used: String Matching Two Pointer / Brute Force Comparison 🧠 Key Learning: The task was to locate the first occurrence of a pattern (needle) inside another string (haystack). I practiced comparing characters sequentially and handling mismatches carefully while traversing the string. ⚡ Insight Gained: Even simple-looking problems help build a strong foundation for advanced string searching algorithms like KMP and Rabin–Karp. Understanding basic string matching logic is essential before moving to optimized pattern-search techniques. Consistency continues 🚀 #100DaysOfLeetCode #LeetCode #DSA #Strings #Algorithms #Java #ProblemSolving #CodingJourney #LearningInPublic #Consistency
LeetCode 28 - Find String Pattern Index
More Relevant Posts
-
🚀 Day 60 of #100DaysOfCode Another recursion problem that initially feels tricky, but becomes much clearer once the pattern is understood. 🌱 Topic: Recursion / Divide & Conquer ✅ Problem Solved: LeetCode 779 – K-th Symbol in Grammar 🛠 Approach: Base Case: n == 1 → return 0 Observed that each row is divided into two halves: First half → same as previous row Second half → inverse of previous row Calculated midpoint: 2^(n-2) If k <= mid → go to left half Else → go to right half and invert result #100DaysOfCode #Day60 #DSA #Recursion #DivideAndConquer #LeetCode #Java #Algorithms #ProblemSolving #CodingJourney #Consistency
To view or add a comment, sign in
-
-
#CodeEveryday — My DSA Journey | Day 2 🧩 Problem Solved: Combination Sum II (LeetCode) 💭 What I Learned: Used backtracking to generate all unique combinations whose sum equals the target. Sorted the array initially to efficiently handle duplicates and enable pruning. At each step: ✔️ Skipped duplicate elements using i > n && nums[i] == nums[i-1] ✔️ Stopped recursion early when the current element exceeded the target ✔️ Moved to the next index (i+1) to avoid reusing elements Strengthened my understanding of handling duplicates in recursion and optimizing search space. ⏱ Time Complexity: O(2ⁿ)*k (k is avg length of each combination) 🧠 Space Complexity: O(n) ⚡ Key Takeaways: ✔️ Sorting helps in both pruning and duplicate handling ✔️ Skipping duplicates is crucial for unique combinations ✔️ Backtracking becomes efficient with early stopping conditions 💻 Language Used: Java ☕ 📘 Concepts: Backtracking · Recursion · Arrays · Duplicate Handling · Pruning #CodeEveryday #DSA #LeetCode #Java #Backtracking #ProblemSolving #Algorithms #CodingJourney #Consistency 🚀
To view or add a comment, sign in
-
-
Day 2 of my LeetCode Journey Today’s focus: Prefix Sum + HashMap - Problem Type: Counting “Good Subarrays” - Approach: Converted the problem into a prefix sum transformation Used a HashMap to track frequencies Optimized brute force (O(n²)) → O(n) Key Learning: The real trick isn’t coding — it’s recognizing how to transform the problem. Instead of checking every subarray, I tracked a derived value: prefix - (index + 1) and counted how many times it appeared before. That shift turns an impossible brute force into a clean linear solution. -Takeaway: Most DSA problems are not about new algorithms — they’re about seeing the hidden pattern faster. Building consistency, one day at a time. #LeetCode #Day2 #DSA #Java #ProblemSolving #Consistency #CodingJourney
To view or add a comment, sign in
-
-
#Day75 of my second #100DaysOfCode Today’s problem was more about spotting patterns than writing code. DSA • Solved Single Element in a Sorted Array (LeetCode 540, Medium) – Brute: linear scan checking pairs → O(n) – Optimal: binary search using index pattern → O(log n) • Key idea: elements appear in pairs, and the single element breaks this pattern • Used position-based logic to decide which half to search This one really showed how observing patterns can simplify the approach. #DSA #BinarySearch #LeetCode #Algorithms #Java #100DaysOfCode #WomenWhoCode #BuildInPublic #LearningInPublic
To view or add a comment, sign in
-
-
🔥 DSA Challenge – Day 133/360 🚀 📌 Topic: Recursion + Memoization 🧩 Problem: Word Break Problem Statement: Check if a given string can be segmented into space-separated words from a given dictionary. 🔍 Example: Input: s = "leetcode", wordDict = ["leet", "code"] Output: true 💡 Approach: Optimized (Recursion + Memoization) 1️⃣ Step 1 – Convert the word list into a HashSet for fast lookup 2️⃣ Step 2 – Try all substrings starting from current index 3️⃣ Step 3 – Use memoization array to avoid recomputation of same index ⏱ Complexity: Time: O(n³) Space: O(n) 📚 Key Learning: Memoization helps avoid repeated work and turns an exponential problem into a polynomial one. #DSA #Java #Coding #InterviewPrep #ProblemSolving #TechJourney #133DaysOfCode #LeetCode
To view or add a comment, sign in
-
-
#100DaysOfCode – Day 2 Today I worked on a DSA problem based on arrays: Check if an array is sorted and rotated 🔍 Approach: Instead of finding the exact rotation point, I focused on identifying a pattern: In a sorted and rotated array, the order should break at most once. So, I checked how many times an element is greater than the next element while traversing the array in a circular manner. ✔️ If the count of such breaks is 0 or 1 → valid ❌ If it’s more than 1 → not a sorted rotated array 🧠 Key Takeaway: This problem taught me how pattern observation can simplify logic and avoid unnecessary complexity. Sometimes the best solution is not the most obvious one! 📈 Staying consistent and improving step by step 💪 #100DaysOfCode #DSA #DataStructures #Algorithms #Java #CodingJourney #ProblemSolving #LeetCode #Consistency
To view or add a comment, sign in
-
-
💡 Day 63 of LeetCode Problem Solved! 🔧 🌟 796. Rotate String 🌟 🔗 Solution Code: https://lnkd.in/dbS6k9gb 🧠 Approach: • Checked if both strings have equal length — if not, instantly return false. • Concatenated s with itself → all possible rotations of s are embedded inside s + s. • Used Java's built-in contains() to check if goal is a substring of the doubled string. ⚡ Key Learning: • A clever observation can replace brute-force rotation simulation entirely. Doubling the string is a go-to trick for rotation problems — simple, elegant, and highly effective. ⏱️ Complexity: • Time: O(N) • Space: O(N) #LeetCode #Java #DSA #ProblemSolving #Consistency #CodingJourney #Algorithms #Strings
To view or add a comment, sign in
-
-
🚀 LeetCode Challenge 7/50 🔍 Problem: Valid Anagram Today’s problem was about checking whether two strings are anagrams of each other efficiently. 💡 Approach: I used the Character Frequency Count method: First checked if both strings have equal length Used an array of size 26 to track character frequencies Incremented counts for one string and decremented for the other If all values are zero, both strings are anagrams ⚡ This approach avoids sorting and ensures optimal performance. 📊 Complexity Analysis: Time Complexity: O(n) Space Complexity: O(1) 📚 Key Learning: Using frequency arrays is a powerful technique for string problems. It helps achieve constant space complexity and improves efficiency compared to sorting-based approaches. Step by step, getting better at problem solving 💪 #LeetCode #Algorithms #DataStructures #ProblemSolving #CodingJourney #Java #100DaysOfCode #StudentDeveloper #Learning
To view or add a comment, sign in
-
-
----Continuing my DSA journey---- * Problem: Parse Lisp Expression (736) * Approach: I solved this using recursion + hashmap (scope handling). I parsed the expression and evaluated it based on three cases: • add → evaluate both expressions and sum • mult → evaluate both expressions and multiply • let → assign variables and evaluate in scoped context I used a HashMap to maintain variable values and passed copies to handle nested scopes correctly. * Key Insight: The tricky part was managing variable scope in nested expressions. Each "let" creates a new scope, and variables must be resolved from inner to outer scope. * What I Learned: This problem improved my understanding of parsing complex expressions and scope management. #LeetCode #DSA #Java #Recursion #HashMap #ProblemSolving
To view or add a comment, sign in
-
-
🚀 LeetCode Problem of the Day 📌 Problem: Minimum Distance to Target Element Given an integer array nums (0-indexed) and two integers target and start, we need to find an index i such that: nums[i] == target |i - start| is minimized 👉 Return the minimum absolute distance. 💡 Key Idea: We simply scan the array and track the minimum distance whenever we find the target. 🧠 Approach Traverse the array Whenever nums[i] == target, compute abs(i - start) Keep updating the minimum result 💻 Java Solution class Solution { public int getMinDistance(int[] nums, int target, int start) { int res = Integer.MAX_VALUE; for (int i = 0; i < nums.length; i++) { if (nums[i] == target) { res = Math.min(res, Math.abs(i - start)); } } return res; } } 📊 Complexity Analysis ⏱ Time Complexity: O(n) → single pass through the array 🧠 Space Complexity: O(1) → no extra space used ⚡ Simple linear scan, optimal solution — sometimes brute force is already the best solution! #LeetCode #Coding #Java #ProblemSolving #DataStructures #Algorithms #InterviewPrep
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