🚀 𝐃𝐚𝐲 𝟐/ 𝟏𝟎𝟎 — 𝐋𝐞𝐧𝐠𝐭𝐡 𝐨𝐟 𝐋𝐚𝐬𝐭 𝐖𝐨𝐫𝐝 (𝐋𝐞𝐞𝐭𝐂𝐨𝐝𝐞 𝟓𝟖) Most people learn string manipulation by just chaining built-in methods. But today made one thing clear 👇 👉 Efficient parsing is about knowing exactly when to stop. 🧠 Today’s Breakthrough: From the "easy way" ➔ to optimized engineering thinking • Built-in .split() ➔ fast to write, but wastes memory on new arrays • Forward traversal ➔ works, but forces you to read the entire string • Backward traversal ➔ starts at the end, uses O(1) space • Early exit ➔ breaks the loop immediately, thinking like a pro Same result. Entirely different levels of performance. 💡 The core idea (Backward Parsing): 👉 Start at the end ➔ skip any trailing spaces 👉 Count characters ➔ track the length of the word 👉 Hit a space again ➔ break the loop immediately Simple rule. Massive impact. #DSA #Java #SoftwareEngineering #LeetCode #CodingJourney #InterviewPrep #LearnInPublic
Optimized String Parsing: Backward Traversal for Efficient Results
More Relevant Posts
-
“What I learned after solving 300+ LeetCode problems 👇” At the beginning, I made a mistake. I kept solving random problems every day thinking: “More problems = more skill” But I was wrong. I realized that solving problems randomly is mostly a waste of time if you don’t understand the pattern behind them. Everything changed when I started focusing on patterns instead of problems. Here are some important patterns I learned: • Sliding Window • Two Pointers • Prefix Sum • Binary Search • Recursion & Backtracking • Linked List Patterns • Stack & Monotonic Stack • Hashing / Frequency Count Once you understand these patterns: You don’t need to solve 1000 problems. You start recognizing solutions instantly. Now when I see a problem, I don’t panic. I ask: 👉 “Which pattern does this belong to?” That one question changed everything for me. Still learning, but now with direction 🚀 #DSA #LeetCode #Java #BackendDevelopment #CodingJourney
To view or add a comment, sign in
-
🚀 Day 52 of #100DaysOfLeetCode Solved: Daily Temperatures (Monotonic Stack) Today’s focus was on understanding how to optimize from a brute-force O(n²) approach to an efficient O(n) solution using a stack. Key takeaways: Learned how to identify “next greater element” patterns Understood how monotonic stacks help avoid redundant work Practiced writing clean and optimized code Consistency is starting to pay off. Onto the next one. #DSA #Java #CodingJourney #LeetCode #ProblemSolving
To view or add a comment, sign in
-
-
🔄 Solved “Spiral Matrix”, a classic matrix traversal problem using boundary-based approach. ✦ What This Problem Taught Me: • How to traverse a 2D matrix layer by layer using boundaries • Effective use of four pointers (top, bottom, left, right) • Managing direction-based traversal (→ ↓ ← ↑) • Importance of shrinking boundaries after each iteration • Avoiding duplicate traversals using proper conditions • Strengthened understanding of 2D arrays and indexing 🚀 Problems like this show how controlling boundaries and direction can simplify complex matrix traversals into a clean O(m × n) solution. On to solving more matrix and pattern-based problems 💪🔥 #LeetCode #DSA #Matrix #TwoPointers #CodingJourney #ProblemSolving #Java #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 26/100 Days of #CodeChallenge Today’s problem: Isomorphic Strings (Leetcode 205) This problem helped me understand how to map characters between two strings while maintaining consistency and order. 💡 Key Concept: Two strings are isomorphic if characters in one string can be replaced to get the other string — with: ✔️ One-to-one mapping ✔️ No two characters mapping to the same character ✔️ Order preserved 🧠 What I Learned: How to use mapping (arrays/hashmaps) efficiently Importance of bidirectional checking Handling edge cases like unequal lengths ⚡ Approach: Compare lengths first Track character mappings using arrays Ensure consistency in both directions ⏱️ Complexity Analysis: Time Complexity: O(n) → We traverse the strings once Space Complexity: O(1) → Fixed-size arrays (256 characters) ✅ Successfully solved and understood the logic! Every day is a step closer to mastering problem-solving 💪 #Day26 #100DaysOfCode #Java #DSA #LeetCode #CodingJourney #ProblemSolving #TechLearning
To view or add a comment, sign in
-
-
There was a time when even starting a problem felt confusing. Reading the question multiple times, not knowing where to begin, and getting stuck often. With consistent practice, things started to change — patterns became familiar, approaches became clearer, and solving started to feel more structured. That consistency has now led to solving 150 problems on LeetCode. Focused on building a strong foundation through arrays, strings, hashing, sliding window, and binary search — spending more time understanding the logic rather than just aiming for accepted submissions. This journey improved: * Problem breakdown and thinking approach * Pattern recognition across questions * Code clarity and structure Currently working on improving speed and taking on more challenging problems. 🔗 LeetCode Profile: https://lnkd.in/gkf7m6wp #LeetCode #DSA #Java #ProblemSolving #Coding #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 𝗗𝗮𝘆 - 48/60 Problem: Rotate Array by One (Right Rotation) 🔍 Learned: To rotate the array by one position to the right, store the last element, shift all elements one step to the right, and place the stored element at the beginning. 😅 Struggles: Initially mixed up left and right rotation logic and tried shifting from left to right, which caused overwriting and wrong results. Also made indexing mistakes like accessing invalid positions. 🧠 Key Learning: Always decide direction first (left vs right) before coding. For right shift, traverse from end to start to avoid overwriting. Store the element that will be lost (last element here) before shifting. 📦 Concepts Used: #Arrays #Traversal #InPlace #LogicBuilding #DSA Direction clarity + correct traversal = clean solution. 🚀 #Java #CodingJourney #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 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
To view or add a comment, sign in
-
-
🚀 Day 13 of LeetCode Problem Solving Solved today’s problem — LeetCode #560: Subarray Sum Equals K 💻🔥 ✅ Approach: Prefix Sum + HashMap ⚡ Time Complexity: O(n) 📊 Space Complexity: O(n) The task was to find the total number of subarrays whose sum equals k. 👉 Instead of checking all subarrays (O(n²)), I used an optimized approach with prefix sum + HashMap. 💡 Key Idea: If currentSum - k already exists in the map, it means a subarray with sum = k is found. 👉 Core Logic: Maintain running sum Check if (sum - k) exists in map Add its frequency to count Store current sum in map 💡 Key Learning: Prefix Sum + HashMap is a powerful pattern for subarray problems — must know for interviews 🚀 Consistency is the key — growing stronger every day 🔥 #Day13 #LeetCode #DSA #Java #CodingJourney #ProblemSolving #100DaysOfCode
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