🚀 Day 3 of My DSA Journey Today was all about Strings & Pattern Matching 🔍 Here’s what I learned: ✅ Anagram Logic Using frequency arrays to compare strings efficiently Learned why c - 'a' is used (index mapping) ✅ String Compression Difference between frequency-based vs consecutive compression Understood why using StringBuilder is important (avoids O(n²)) ✅ KMP Algorithm (Game Changer!) Learned how to search patterns in O(n + m) time Key idea: Don’t restart, jump using LPS Understood LPS (Longest Prefix = Suffix) with step-by-step dry run 💡 Biggest takeaway: 👉 Writing code is easy, but understanding why it's optimal is what really matters. ⚡ From brute force → optimized thinking That shift is the real progress. #DSA #100DaysOfCode #Java #ProblemSolving #LearningJourney #Coding
Day 3 of DSA Journey: Strings & Pattern Matching
More Relevant Posts
-
🚀 Day 3 – Strings, Patterns & Optimizations! Today I dove deep into string problems and realized how much optimization matters. 💡 Highlights from Day 3: Anagram Check: Learned to map characters using frequency arrays. Why c - 'a' works now makes total sense. String Compression: Counting frequencies vs handling consecutive duplicates efficiently. Realized StringBuilder is a life-saver for performance. KMP Algorithm: Pattern searching without restarting. LPS array is the secret sauce! Learned to find patterns in O(n + m) time. 🔥 Key Lesson: It’s not just about solving a problem—it’s about solving it efficiently. Knowing the theory behind the code makes all the difference. From brute-force thinking → optimized thinking, every day I’m leveling up my coding skills. #DSA #Java #100DaysOfCode #CodingJourney #ProblemSolving #LearningDaily
To view or add a comment, sign in
-
🧠 Day 41 / 100 – DSA Practice Solved Count and Say on LeetCode 🔢🗣️✅ 🔹 Problem: Generate the nth term of the count-and-say sequence, where each term is derived by describing the previous term. 🔹 Approach: Used an iterative + string building approach: Start with base case "1" For each iteration, read the previous string Count consecutive characters Append count + character to form next term 🔍 Key Insight: This problem is essentially Run-Length Encoding (RLE) applied repeatedly on strings 🔹 Complexity: ⏱ Time → O(n × m) (m = length of generated string) 📦 Space → O(m) 💯 Result: ✔️ All test cases passed ⚡ Runtime: 8 ms (Beats 62%) Great problem to improve string manipulation & pattern recognition 🚀 #Day41 #100DaysOfCode #LeetCode #Java #DSA #Strings #RLE #Algorithms #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 48 of My DSA Journey Solved: Roman to Integer (LeetCode #13) Today’s problem focused on understanding how Roman numerals translate into integers using mapping and pattern recognition. 🔍 Key Learnings: • Learned how to use a HashMap for value mapping • Understood the concept of subtractive notation (like IV = 4, IX = 9) • Improved my ability to handle string traversal with conditions • Strengthened logic-building for edge cases 💡 Approach: Instead of simply adding values, I checked if the current symbol is smaller than the next one. If yes → subtract logic If no → add normally 📌 This problem helped me realize how small conditions can change the entire logic flow. #Day48 #DSA #LeetCode #Java #CodingJourney #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Day 45 of Daily DSA 🚀 Solved LeetCode 867: Transpose Matrix ✅ Problem: Given a 2D matrix, return its transpose (rows become columns and columns become rows). Approach: Created a new matrix and swapped indices while traversing. Steps: Get number of rows and columns Create a new matrix of size cols x rows Traverse original matrix Assign: trans[j][i] = matrix[i][j] Return the new matrix ⏱ Complexity: • Time: O(n × m) • Space: O(n × m) 📊 LeetCode Stats: • Runtime: 0 ms (Beats 100%) ⚡ • Memory: 46.46 MB Simple transformations like transpose build strong fundamentals for matrix-based problems 💡 #DSA #LeetCode #Java #Arrays #Matrix #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
Day 26 #SDE focused on sliding window and voting algorithm patterns. Solved: • Permutation in String • Majority Element II Key Learning: • “Permutation in String” uses the sliding window + frequency count approach to efficiently check if any permutation of one string exists in another. • “Majority Element II” is a great example of the Boyer-Moore Voting Algorithm, which helps find elements appearing more than ⌊n/3⌋ times in O(n) time and O(1) space. #LeetCode #DSA #SlidingWindow #Algorithms #Java #SoftwareEngineering
To view or add a comment, sign in
-
✨ Day 41 of 90 – Pattern Mastery Journey 🧠 Pattern:Reverse Alphabet Hash Pattern 💡 Approach: ✔ Used reverse looping (n → 1) to build the pattern ✔ Printed alphabets using ASCII logic `(char)('A' + i - 1)` ✔ Printed alphabet `i` times in each row ✔ Filled remaining positions with `#` using `(n - i)` ✔ Maintained proper structure and alignment 🚀 This problem helped me understand how reversing loops can change the entire pattern structure and improve control over output formatting. #PatternMasteryJourney #Java #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
Day 56/100 | #100DaysOfDSA 🧠⚡ Today’s problem: String Compression A clean in-place array manipulation problem. Core idea: Compress consecutive repeating characters and store the result in the same array. Approach: • Traverse the array using a pointer • Count consecutive occurrences of each character • Write the character to the array • If count > 1 → write its digits one by one • Move forward and repeat Key insight: We don’t need extra space — just carefully manage read & write pointers. Time Complexity: O(n) Space Complexity: O(1) Big takeaway: In-place algorithms require precise pointer control but give optimal space efficiency. Mastering these improves real-world memory optimization skills. 🔥 Day 56 done. #100DaysOfCode #LeetCode #DSA #Algorithms #Strings #TwoPointers #InPlace #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity
To view or add a comment, sign in
-
-
📊 DSA Progress Update – Week 5 Over the past few days, I’ve been practicing array problems and improving my approach step by step. What I learned: • Starting with a brute force solution helps in understanding the problem clearly • Optimization becomes easier once the pattern is identified • Key techniques : - Two Pointers - Sliding Window - Prefix Sum - Kadane’s Algorithm Something new: Started learning Binary Search and understanding its basic approach. Plan: Continue practicing and get more comfortable with these concepts. Taking it one step at a time. #DSA #Java #LeetCode #Consistency #CodingJourney
To view or add a comment, sign in
-
🚀 Day 121/500 – LeetCode DSA Challenge Today I solved three problems focused on strings and number manipulation. ✅ Reverse String II – Reversed every k characters using two pointers. TC: O(n) | SC: O(n) ✅ Reverse Only Letters – Applied two-pointer approach while skipping non-letter characters. TC: O(n) | SC: O(n) ✅ Digitorial Permutation – Calculated factorial sum of digits and checked digit frequency match. TC: O(d) | SC: O(1) 💡 Key Learning: Two-pointer techniques simplify many string problems, and digit-based problems often rely on frequency counting and math logic. 👉 Day 121/500 #DSA #Java #500DaysChallenge #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
📘 DSA Journey — Day 35 Today’s focus: Binary Search with index patterns. Problem solved: • Single Element in a Sorted Array (LeetCode 540) Concepts used: • Binary Search • Index parity (even/odd pattern) • Search space reduction Key takeaway: The array is sorted and every element appears twice except one. A key observation: Before the single element, pairs start at even indices After the single element, this pattern breaks. Using binary search: • If mid is even and nums[mid] == nums[mid + 1], the single element lies on the right side • Else, it lies on the left side (including mid) By leveraging this pattern, we can find the answer in O(log n) time and O(1) space. Continuing to strengthen binary search intuition and consistency in problem solving. #DSA #Java #LeetCode #CodingJourney
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