𝗗𝗮𝘆 𝟮𝟳/𝟭𝟬𝟬 | 𝗗𝗲𝗰𝗼𝗱𝗲 𝗦𝘁𝗿𝗶𝗻𝗴 Day 27 ✅ — When recursion makes everything elegant. 𝗧𝗼𝗱𝗮𝘆'𝘀 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: ✅ 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 #𝟯𝟵𝟰: Decode String (Medium) 𝗪𝗵𝗮𝘁 𝗖𝗹𝗶𝗰𝗸𝗲𝗱: Decode strings like "3[a2[c]]" → "accaccacc". Numbers indicate repetition, brackets show nested patterns. My first thought? Stack. But then I realized: nested brackets = 𝗿𝗲𝗰𝘂𝗿𝘀𝗶𝗼𝗻 territory. Each time I hit '[', recursively decode what's inside. When I hit ']', return to the outer level. The recursion naturally handles the nesting. 𝗠𝘆 𝗔𝗽𝗽𝗿𝗼𝗮𝗰𝗵: 👉 Build number from consecutive digits 👉 When '[' appears, recursively decode inner string 👉 Repeat the decoded string by the number 👉 When ']' appears, return result to caller 👉 Regular characters get appended directly Time: O(maxK × n) where maxK is max repeat count, Space: O(n) for recursion stack 𝗠𝘆 𝗥𝗲𝗮𝗹𝗶𝘇𝗮𝘁𝗶𝗼𝗻: Recursion isn't just for trees and graphs—it's for any problem with 𝗻𝗲𝘀𝘁𝗲𝗱 𝘀𝘁𝗿𝘂𝗰𝘁𝘂𝗿𝗲𝘀. The key: recognize when a subproblem looks exactly like the main problem. That's your recursion signal. 27 days in, and I'm getting more comfortable with recursive thinking. 𝗖𝗼𝗱𝗲: https://lnkd.in/gFfUH6bk 𝟮𝟳 𝗱𝗮𝘆𝘀 𝘀𝘁𝗿𝗮𝗶𝗴𝗵𝘁. 𝗔𝗹𝗺𝗼𝘀𝘁 𝗮 𝗺𝗼𝗻𝘁𝗵. Every problem teaches a pattern. Every pattern becomes a tool. 𝗗𝗮𝘆 𝟮𝟳/𝟭𝟬𝟬 ✅ | 𝟳𝟯 𝗺𝗼𝗿𝗲 𝘁𝗼 𝗴𝗼! #100DaysOfCode #LeetCode #Recursion #StringManipulation #DataStructures #CodingInterview #TechnicalInterview #SoftwareEngineer #FAANG #ProblemSolving #Algorithms #Java #Programming #ComputerScience #DeveloperJourney #LearnInPublic #SoftwareDevelopment #CodingSkills #TechJobs #CareerGrowth
More Relevant Posts
-
hi connections I recently revisited LeetCode 7: Reverse Integer, and it’s a perfect reminder that the "easy" way isn't always the "right" way in engineering. On the surface, reversing an integer sounds like a task for a beginner. But the real challenge lies in the 32-bit signed integer constraint. In a modern environment with high-level languages, it’s easy to forget that hardware has hard limits. The Engineering Mindset: The problem explicitly forbids storing 64-bit integers. This means you can't just reverse the number and check the size afterward—you have to predict the overflow before it happens. The Core Strategy: Mathematical Extraction: Instead of converting to a string (the "shortcut"), using modular arithmetic to pop the last digit. The Rebuild: Shifting the result by a factor of 10 and pushing the new digit in. The Guardrail: The real work is the Overflow Check. You have to verify that your next multiplication won't exceed 2^{31} - 1 or fall below -2^{31}. The Takeaway: This isn't just a coding puzzle; it’s an exercise in defensive programming. It forces you to think about how data is handled at the machine level and reminds us that edge cases—like boundary overflows—are not just "possibilities," they are requirements. In a world of "infinite" memory, staying sharp on these constraints is what separates a coder from an engineer. How do you approach these boundary-testing problems? Do you go for the quick string manipulation, or do you prefer the mathematical rigor? Let’s talk about it in the comments! 👇 #LeetCode #SoftwareEngineering #ProblemSolving #CodingInterviews #Python #CleanCode #ProgrammingConstraints #DataStructures
To view or add a comment, sign in
-
-
𝗗𝗮𝘆 𝟱𝟭/𝟭𝟬𝟬 | 𝗜𝗻𝘀𝗲𝗿𝘁𝗶𝗼𝗻 𝗦𝗼𝗿𝘁 𝗟𝗶𝘀𝘁 Day 51 ✅ — Second half begins. 𝗧𝗼𝗱𝗮𝘆'𝘀 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: ✅ 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 #𝟭𝟰𝟳: Insertion Sort List (Medium) 𝗪𝗵𝗮𝘁 𝗖𝗹𝗶𝗰𝗸𝗲𝗱: Sort a linked list using insertion sort. The algorithm everyone learns with arrays—now applied to pointers. For each unsorted node, find its correct position in the sorted portion and insert it there. The dummy node pattern made this clean—find the insertion point, adjust pointers, move forward. Day 51. The second half of the journey starts here. 𝗠𝘆 𝗔𝗽𝗽𝗿𝗼𝗮𝗰𝗵: 👉 Dummy node for sorted list head 👉 Keep sorted and unsorted portions 👉 For each unsorted node, find insertion position 👉 Adjust pointers to insert node 👉 Continue until entire list is sorted Time: O(n²), Space: O(1) 𝗠𝘆 𝗥𝗲𝗮𝗹𝗶𝘇𝗮𝘁𝗶𝗼𝗻: Twenty-two linked list problems. Insertion sort on arrays is basic. On linked lists? It tests if you truly understand pointer manipulation. Yesterday was celebration. Today is execution.𝟰𝟵 𝗺𝗼𝗿𝗲 𝗱𝗮𝘆𝘀. 𝗟𝗲𝘁'𝘀 𝗴𝗼. 𝗖𝗼𝗱𝗲:🔗 https://lnkd.in/gR6h_43V 𝗗𝗮𝘆 𝟱𝟭/𝟭𝟬𝟬 ✅ | 𝟰𝟵 𝗺𝗼𝗿𝗲 𝘁𝗼 𝗴𝗼! #100DaysOfCode #LeetCode #LinkedList #InsertionSort #SortingAlgorithms #DataStructures #CodingInterview #SoftwareEngineer #Java #Algorithms #Programming #SecondHalf
To view or add a comment, sign in
-
🚀 Day 63/100 – #LeetCodeChallenge 📌 Problem: Count Binary Substrings Today’s problem was all about spotting patterns in binary strings — and it turned out to be a fun exercise in run-length encoding logic! 🧠 🔍 Approach: Instead of storing counts separately, I used a simple linear scan to keep track of consecutive identical characters (strk) and the length of the previous run (prev). Whenever a run ends, we update prev and reset strk. Then, if the current streak is ≤ the previous one, it means we’ve found a valid substring — and we increment the result. 📈 ⚡ Result: ✅ Runtime: 10 ms – beats 87.50% 🚀 💾 Memory: 46.44 MB – beats 56.68% Feeling good about the balance between time and space efficiency here! Every day is a step closer to mastering problem-solving patterns. 💪 🔗 Takeaway: Sometimes the most elegant solutions come from simple observation — no need for complex data structures when a single pass and a few variables do the trick! #100DaysOfCode #LeetCode #Java #CodingChallenge #ProblemSolving #TechJourney #DevCommunity #StringManipulation #Algorithms #CodeNewbie #SoftwareEngineering #WomenInTech #CodingLife #InterviewPrep #DataStructures #DailyCoding
To view or add a comment, sign in
-
-
𝗗𝗮𝘆 𝟯𝟮/𝟭𝟬𝟬 | 𝗥𝗲𝗺𝗼𝘃𝗲 𝗡𝘁𝗵 𝗡𝗼𝗱𝗲 𝗙𝗿𝗼𝗺 𝗘𝗻𝗱 𝗼𝗳 𝗟𝗶𝘀𝘁 Day 32 ✅ — Three linked list problems in a row. The pattern is clear. 𝗧𝗼𝗱𝗮𝘆'𝘀 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: ✅ 𝗣𝗿𝗼𝗯𝗹𝗲𝗺 #𝟭𝟵: Remove Nth Node From End of List (Medium) 𝗪𝗵𝗮𝘁 𝗖𝗹𝗶𝗰𝗸𝗲𝗱: Remove the nth node from the end of a linked list in one pass... or two. The tricky part? We don't know the size upfront. My approach: first calculate the size, then find the exact node to remove. Key edge case that almost caught me: removing the head node itself (when n equals the list size). Had to handle that separately. 𝗠𝘆 𝗔𝗽𝗽𝗿𝗼𝗮𝗰𝗵: 👉 First pass: calculate the total size of the linked list 👉 If n equals size, remove head directly 👉 Traverse to the node just before the target 👉 Skip the target node: curr.next = curr.next.next Time complexity: O(n), Space complexity: O(1) 𝗠𝘆 𝗥𝗲𝗮𝗹𝗶𝘇𝗮𝘁𝗶𝗼𝗻: This is a two-pass solution. There's also a one-pass two-pointer technique using fast and slow pointers—something I want to explore next. But here's what matters: my solution works, is clean, and handles all edge cases. Understanding multiple approaches to the same problem is what separates good developers from great ones in technical interviews. Three linked list problems back-to-back (Day 30, 31, 32) and the pointer manipulation is becoming second nature. 𝗖𝗼𝗱𝗲: https://lnkd.in/g5EEbZKW 𝟯𝟮 𝗱𝗮𝘆𝘀. 𝗟𝗶𝗻𝗸𝗲𝗱 𝗹𝗶𝘀𝘁 𝗺𝗮𝘀𝘁𝗲𝗿𝘆 𝘂𝗻𝗹𝗼𝗰𝗸𝗲𝗱. 𝗗𝗮𝘆 𝟯𝟮/𝟭𝟬𝟬 ✅ | 𝟲𝟴 𝗺𝗼𝗿𝗲 𝘁𝗼 𝗴𝗼! #100DaysOfCode #LeetCode #LinkedList #PointerManipulation #TwoPointer #DataStructures #CodingInterview #TechnicalInterview #FAANG #SoftwareEngineer #Java #Algorithms #EdgeCases #ComputerScience #Programming #TechCareers #Consistency
To view or add a comment, sign in
-
⚡#LeetcodeProblemPractice | ⚡0 ms Runtime. 100% Beat. One Line of Logic. Just crushed Rotate String — a problem that looks trivial but rewards pattern recognition over brute force. 🧠 Problem Snapshot We’re given two strings: s and goal. We can repeatedly move the first character to the end. Need to check if s can transform into goal. Example: abcde → bcdea → cdeab 💡 Breakthrough Insight If a string can be rotated to form another string, then: goal must be a substring of s + s Why? Because concatenating a string with itself contains every possible rotation. So instead of simulating shifts (slow brain strategy ❌), we do string pattern containment (big brain strategy ✅). 💻 Code (Java) class Solution { public boolean rotateString(String s, String goal) { if (s.length() != goal.length()) { return false; } return (s + s).contains(goal); } } ⚙️ Complexity MetricValueTimeO(n)SpaceO(n) (for s+s) Efficient. Elegant. Interview gold. 📊 Performance MetricResultRuntime0 ms 🚀MemoryTop 4% 💪 🎯 What This Teaches ✅ Pattern recognition > simulation ✅ Clever string transformations ✅ Turning problems into substring checks ✅ Writing shorter code with stronger logic This is the type of question where overthinking loses and insight wins. #LeetCode #DSA #Algorithms #Strings #CodingInterview #ProblemSolving #JavaDeveloper #SoftwareEngineering #CompetitiveProgramming #InterviewPrep #ProgrammingLife #CodeDaily #Developers #ComputerScience #TechCareers #CodingJourney #DataStructures #FAANGPrep #GreedyThinking #Optimization #LearnToCode #CodeSmart #EngineeringLife #AIEngineer #TechCommunity #CareerGrowth Back to stacking wins. 🧠💻
To view or add a comment, sign in
-
-
Day 8 – DSA Journey | Arrays 🚀 Today’s problem pushed me to think in terms of recursion 🔁, constraints 🧩, and backtracking ⏪ rather than simple iteration. 𝐏𝐫𝐨𝐛𝐥𝐞𝐦 𝐒𝐨𝐥𝐯𝐞𝐝 • 🧠 Sudoku Solver 🔹 Sudoku Solver 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡 • 🔁 Used backtracking to try all valid possibilities • 📊 Tracked constraints using boolean matrices for rows, columns, and 3×3 boxes • ✅ Placed a number only if it was valid across all constraints 𝐇𝐨𝐰 𝐢𝐭 𝐖𝐨𝐫𝐤𝐬 • 🔍 Find the first empty cell • 🔢 Try numbers from 1–9 • ▶️ Recurse if placement is valid • ⏪ Backtrack if it leads to an invalid state 𝐊𝐞𝐲 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠𝐬 • 💡 Backtracking is about choices, recursion, and undoing • ⚡ Pre-tracking constraints avoid repeated checks • 🧠 Clear constraints make recursion easier to reason about • 🛑 Clean base cases prevent infinite recursion 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲 • ⏱ Time: Exponential (heavily pruned by constraints) • 📦 Space: O(1) (fixed board + recursion stack) 🧠 𝐓𝐚𝐤𝐞𝐚𝐰𝐚𝐲 Backtracking isn’t brute force — it’s controlled exploration with rules 🎯 On to Day 9 🔁🚀 #DSA #Arrays #Backtracking #Recursion #LeetCode #Java #ProblemSolving #DailyCoding #LearningInPublic #SoftwareDeveloper
To view or add a comment, sign in
-
-
🚀 Today’s LeetCode Problem — Sort Integers by Number of 1 Bits Let’s solve today’s LC in story mode 🎭 Imagine numbers are contestants in a Binary Costume Contest. Today’s contestants: 👉 [5, 3, 7] But this contest has a twist 👇 👨⚖️ The judge doesn’t care about the number itself first. He cares about… 🎈 How many 1s are in their binary costume 🎭 What Are They Wearing? 🔹 5 → 101 → 🎈🎈 (2 ones) 🔹 3 → 011 → 🎈🎈 (2 ones) 🔹 7 → 111 → 🎈🎈🎈 (3 ones) 🏆 Judge’s Rules 1️⃣ Fewer 1s → Higher priority 2️⃣ Same number of 1s → Smaller number wins 👉 Step 1: 3 & 5 → 2 ones 7 → 3 ones So 7 goes last. 👉 Step 2: Tie between 3 and 5 Smaller number first → 3 before 5 ✅ Final Answer: [3, 5, 7] 💡 How I Solved It I implemented this using: 🔹 Brian Kernighan’s Algorithm for efficient bit counting 🔹 TreeMap to maintain sorted order by bit count + value 🔹 Also compared with built-in bitCount() + custom comparator sorting This ensures: ✔ Efficient bit counting ✔ Clean tie-breaking ✔ Optimal sorting logic If you’re interested, I’ve pushed the complete solution (Kernighan + TreeMap + built-in approach) : https://lnkd.in/gV9HZ9w4 👨💻 Would love feedback from fellow developers 🙌 #LeetCode #DSA #Java #ProblemSolving #CodingJourney #100DaysOfCode #Tech #SoftwareEngineering
To view or add a comment, sign in
-
-
✳️Day 6 of #100DaysOfCode Mastering Linked Lists: Palindromes and Cycle Detection! 💡 I’ve been diving deep into Linked List patterns lately, and I just wrapped up two classic challenges that really test your understanding of pointer manipulation and memory efficiency. 1️⃣ Palindrome Linked List 🔄 The goal:- Determine if a linked list reads the same forward and backward. Approach:- I used an ArrayList to store the node values, then applied a Two-Pointer technique to compare elements from both ends. Key Takeaway:- While this approach is intuitive with O(n) time complexity, the next challenge is to optimize the space to O(1) by reversing the second half of the list in place! 2️⃣ Length of Loop in Linked List ➰ The goal:- Detect if a cycle exists and find exactly how many nodes are in that loop. Approach:- I implemented Floyd’s Cycle-Finding Algorithm (Slow and Fast pointers). Once the pointers met, I held one steady and moved a temporary pointer around the loop to count the nodes. Key Takeaway:- This "Tortoise and Hare" method is incredibly powerful for detecting cycles without using extra memory. Step by step, the logic is getting sharper! On to the next one. 👨💻 #Coding #Java #DataStructures #Algorithms #LeetCode #GeeksForGeeks #ContinuousLearning #ProblemSolving
To view or add a comment, sign in
-
🚀 Day 2/30 – LeetCode Challenge Solved “Majority Element” today using the Boyer–Moore Voting Algorithm. 🔹 Problem: Find the element that appears more than ⌊n/2⌋ times in an array. 🔹 Requirements: ✔ O(n) Time Complexity ✔ O(1) Space Complexity 💡 Approach Used – Boyer–Moore Voting Algorithm Instead of using a HashMap (which takes extra space), I used an optimized approach: Maintain a candidate and a count If count becomes 0 → update candidate If number equals candidate → increment count Else → decrement count This works because the majority element will always survive the cancellation process. ⚡ Result: ✅ Accepted (53/53 test cases) ⚡ Runtime: 1 ms (Beats 99.82%) 💾 Memory: 55.75 MB 📚 Learning: Today’s problem taught me how powerful algorithmic thinking can replace brute force solutions. Space optimization makes a big difference in interviews. On to Day 3 💪 #Day2 #30DaysOfCode #LeetCode #Java #Algorithms #DataStructures #BoyerMoore #ProblemSolving #CodingJourney #SoftwareEngineeringStudent #Consistency #TechGrowth
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