Day 5/30 of #30DaysOfDSA 🔹 Problem: Decode String 💡 Approach: Used a stack-based approach to handle patterns like k[encoded_string], especially nested ones. Stored counts and previous strings, and built the result step-by-step while traversing. ⚡ What I Learned: • Handling nested structures using stacks • Efficient string building • Optimizing parsing logic Complexity: O(n) #DSA #Coding #Java #Consistency
Stack-based Approach to Decode String in Java
More Relevant Posts
-
🚀 Day 7 of #LeetCode Challenge 🔍 Problem: Sqrt(x) 💡 Approach: Used the built-in Math.sqrt() function to compute the square root and then typecasted it to an integer to get the floor value. 🧠 Key Concept: Understanding how to convert a floating-point result into an integer using typecasting. 🔥 #Day7 #LeetCode #Java #DSA #CodingJourney #Consistency
To view or add a comment, sign in
-
-
=>Day 17/90 DSA Journey Solved: Continuous Subarray Sum (LeetCode) Today I worked on an interesting problem involving Prefix Sum + HashMap, which helped me optimize from a brute-force O(n²) solution to an efficient O(n) approach. If the same remainder (sum % k) appears again, it means the subarray between those indices has a sum divisible by k. -> What I learned: How to use prefix sum effectively Importance of storing remainders in HashMap Handling edge cases like subarray length ≥ 2 ->Optimization: Brute Force → O(n²) ❌ Optimized Approach → O(n) ✅ #LeetCode #DSA #Java #Coding #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
💻 Day 80 – DSA Practice (Binary Trees) Today’s challenge: 👉 Find all root-to-leaf paths where the sum equals a given target. 🔹 Approach: Use Depth-First Search (DFS) Track the current path and remaining sum When reaching a leaf node, check if the sum matches 💡 Key Concepts: Recursion + Backtracking Tree traversal (DFS) Efficient sum handling ⚡ Insight: Reducing the target sum at each step makes the solution cleaner and avoids recalculating sums. #DSA #BinaryTree #Java #CodingJourney #100DaysOfCode #ProblemSolving
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 58 of #100DaysOfCode Solved – Check Balanced String 🔍 What I did: Traversed the string and calculated the sum of digits at even and odd indices separately, then compared both sums to determine if the string is balanced. 💡 Key Learning: Practiced string traversal and indexing Improved understanding of even vs odd index logic Learned how to convert char to integer (c - '0') 🎯 Takeaway: Even simple index-based problems can strengthen your fundamentals and attention to detail. #Day58 #LeetCode #Java #ProblemSolving #CodingJourney #100DaysOfCode #DSA
To view or add a comment, sign in
-
-
#Day361 of #1001DaysOfCode 📘 LeetCode Daily Challenge Problem: XOR After Queries 💡 Approach: Simulated each query by updating elements in the array based on the given step and multiplier, and finally computed the XOR of all elements. This approach works correctly but can be further optimized for large inputs using better range update techniques. ⏱ Time Complexity: O(q * n) 🧠 Space Complexity: O(1) Learning to identify optimization opportunities in problems 🚀 #DSA #Java #LeetCode #ProblemSolving #Coding
To view or add a comment, sign in
-
-
🚀 Day 60/100 📌 Problem: String to Integer Given a string, convert it into a 32-bit signed integer while: • Ignoring leading whitespaces • Handling '+' and '-' signs • Reading digits until a non-digit appears • Returning INT_MAX or INT_MIN in case of overflow 💡 What I Learned: • Importance of handling edge cases • How to safely manage overflow • Writing clean and efficient parsing logic ⚡ Result: Runtime 1 ms (Beats 100%) Consistency + Practice = Improvement 📈 #Day60 #Java #DSA #LeetCode #CodingJourney #ProblemSolving #100DaysOfCode #LearnToCode
To view or add a comment, sign in
-
-
Day 82 of DSA Journey Solved Isomorphic Strings today! This problem looks simple, but it teaches an important concept — one-to-one mapping between characters. 🔍 What I learned: Each character in one string must map to exactly one character in the other No two characters should map to the same character Consistency across the entire string is key 💡 Approach: Used two HashMaps to track mappings in both directions: s → t t → s This avoids conflicts and ensures correctness. 🧠 Example: "paper" → "title" ✅ "foo" → "bar" ❌ ✨ Key takeaway: Always think about bidirectional mapping when dealing with transformation problems. Small problem, but powerful concept! #DSA #Java #CodingJourney #100DaysOfCode #ProblemSolving
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
-
-
Day 72 of #100DaysOfCode Problem: Convert Sorted Array to Height-Balanced BST Today I learned how to efficiently convert a sorted array into a balanced Binary Search Tree using Divide & Conquer. Key Insight: Pick the middle element as the root to maintain balance. Recursively build: Left subtree from left half Right subtree from right half This ensures: Optimal height Faster search operations ⏱ Time Complexity: O(n) 📦 Space Complexity: O(log n) Consistency is the real game changer #DSA #Java #BinaryTree #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
Keep it up 👍