🚀 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
Optimizing String Pattern Recognition with Concatenation Trick
More Relevant Posts
-
🚀 Day 66 of #LeetCode Challenge ✅ Problem Solved: Divide a String Into Groups of Size K 💡 What I learned today: • Learned how to break a string into fixed-size groups • Understood how to handle incomplete groups using a fill character • Practiced building strings step-by-step using loops • Improved clarity on index handling and conditions 🧠 Approach: • Traverse the string one character at a time • Build a group until it reaches size k • Store the group and reset • If the last group is smaller, fill remaining positions with the given character 📊 Key Takeaway: Handling edge cases (like incomplete groups) is very important in problem solving 🔥 Consistency is the key — improving step by step every day! #Day66 #LeetCode #CodingJourney #DSA #Java #ProblemSolving #Consistency
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
-
-
Today I solved: Longest Consecutive Sequence 💡 Key Takeaway: Sorting seems like the obvious approach, but it’s not the most optimal. By using a HashSet, we can reduce the time complexity and achieve an O(n) solution. 👉 Approach: - Store all elements in a Set - Start sequence only when the previous number is not present - Count the length of consecutive numbers 📊 Time Complexity: O(n) 🔍 What I learned: Sometimes the best solution comes from avoiding unnecessary work (like sorting) and thinking in terms of direct lookup using hashing. Optimizing the approach is as important as solving the problem 💪 #DSA #LeetCode #Java #CodingJourney #SoftwareEngineering
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 53 of #100DaysOfLeetCode Solved: Next Greater Element (Leetcode 496) Today’s problem was a great reminder of how powerful Monotonic Stack can be for optimization. 🔹 Approach: Used a stack to maintain decreasing elements Mapped each element to its next greater using a HashMap Reduced time complexity from O(n²) → O(n) 🔹 Key Learning: Small mistakes in conditions (like missing a !) can completely break logic. Attention to detail matters just as much as understanding the concept. 🔹 Complexity: Time: O(n + m) Space: O(n) Consistency > Perfection. Showing up daily and improving step by step. #LeetCode #DSA #Java #CodingJourney #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
-
-
🚀 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 59 of My Consistency Journey Today, I solved String Compression (LeetCode 443) — and honestly, it taught me a powerful lesson about thinking beyond brute force. 🔍 Key Learning: At first, I was tempted to use a HashMap to count frequencies, but that approach fails because this problem is about consecutive characters, not total frequency. 💡 Core Concept: 👉 Use Two Pointers (i & j) i → reads and counts characters j → writes compressed result 📌 Main Idea: "Group → Count → Write" Example: Input: a a a b c c Output: a3 b c2 ⚡ Important Insight: Handling counts like 12 or 15 means writing digits separately ('1', '2'), not as a single number. 🧠 What I Improved Today: Understanding in-place array modification Mastering two-pointer technique Writing optimized and clean logic Consistency is slowly turning confusion into clarity 💯 #Day59 #100DaysOfCode #Java #DSA #LeetCode #CodingJourney #PlacementPreparation #KeepLearning
To view or add a comment, sign in
-
-
Day: 96/365 📌 LeetCode POTD: Minimum Distance to Type a Word Using Two Fingers Hard Key takeaways/Learnings from this problem: 1. This problem is a great example of DP with state as both fingers’ positions, which feels tricky at first but clicks once you model it right. 2. Key learning: instead of deciding both fingers every time, fix one and optimize the movement of the other to reduce complexity. 3. Precomputing distances between characters makes transitions much faster and keeps the code clean. #POTD #365DaysOfCode #DSA #Java #ProblemSolving #LearningInPublic #Consistency 🥷
To view or add a comment, sign in
-
-
🚀 Day 27/100 Days of Code Challenge Today’s problem: Find Peak Element (Leetcode 162) 🔍 What I learned: How to find a peak element efficiently without scanning the entire array Using Binary Search to reduce time complexity from O(n) to O(log n) Understanding how the “slope” of elements helps decide the search direction 🧠 Key Idea: Instead of checking every element, compare the middle element with its neighbor: If nums[mid] < nums[mid + 1] → move right Else → move left ✅ Example: Input: [1, 2, 3, 1] Output: 2 (index of peak element 3) Consistency is key 🔑 — improving problem-solving skills one day at a time! 💪 #Day27 #100DaysOfCode #LeetCode #BinarySearch #DSA #Java #CodingJourney
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