Day 46 — #100DaysOfLeetCode 🚀 Problem: Remove Duplicate Letters (LeetCode 316) ✅ Approach: Used a Stack + Greedy approach to build the smallest lexicographical string with unique letters. ⚡ Complexity: O(n) Learning: Strengthened understanding of stack-based string manipulation and greedy logic 🔠 #LeetCode #100DaysOfCode #DSA #Strings #Stack #GreedyAlgorithm #ProblemSolving #CodingJourney
Solved LeetCode 316 with Stack and Greedy approach
More Relevant Posts
-
Day 47 — #100DaysOfLeetCode 🚀 Problem: Reverse Words in a String (LeetCode 151) ✅ Approach: Trim spaces, split the string, reverse the words, and join them back. ⚡ Complexity: O(n) Learning: Improved string handling and manipulation efficiency 🔁 Every line of code adds clarity and confidence 💪 #LeetCode #100DaysOfCode #DSA #Strings #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 37 of #100DaysOfCode Challenge 🚀 🧠 Problem: 🧩 LeetCode 282 — Expression Add Operators (Hard) This problem was all about exploring backtracking with arithmetic logic. We’re given a string of digits and need to insert +, -, or * between them to reach a target value. ⚙️ Approach Used backtracking to: -Pick every possible substring as the next number. -Try adding each operator before it (+, -, *). -Track three things: -current value → total so far -previous operand → to handle multiplication correctly -expression → the string we’re building -Also skipped invalid paths like numbers with leading zeros. 📘 Learning -Understood how to evaluate expressions on the fly without using eval(). -Learned to manage operator precedence (* before +/-) using recursion and previous operand adjustment. -Realized that some problems can’t be optimized further — they test how well you can prune and organize recursion. #100DaysOfCode #DSA #CodingChallenge #StriversSheet #ProblemSolving #TakeUForward #Recursion #CodingInterview #ProgrammingTips #LeetCode #Backtracking
To view or add a comment, sign in
-
-
🔥 Day 92 of My LeetCode Journey — Problem 28: Find the Index of the First Occurrence in a String 💡 Problem Insight: Today’s problem was about finding the first occurrence of a substring (needle) inside another string (haystack). Essentially, it’s like implementing your own version of the strStr() function — a classic problem in string searching. 🧠 Concept Highlight: This challenge sharpens understanding of string traversal and pattern matching. The intuitive solution uses simple iteration and substring comparison, while the optimized approach can involve algorithms like KMP (Knuth-Morris-Pratt) for efficient searching. 💪 Key Takeaway: Sometimes, even built-in functions hide deep logic beneath simplicity — mastering these fundamentals builds confidence for more advanced string algorithms. ⚙️ Daily Reflection: Every search begins with clarity — whether in code or in life. Precision and patience always lead to the right match. #Day92 #LeetCode #100DaysOfCode #StringSearch #PatternMatching #ProblemSolving #DSA #CodingJourney #LearnByDoing #SoftwareEngineering
To view or add a comment, sign in
-
-
🌿Day 65 LeetCode: Generate Parentheses (22) Approach: Backtracking 🔁 ✨ Used recursion to build all valid combinations of parentheses. At each step, we can add '(' if we still have opens left, and ')' only if it doesn’t make the string invalid (close < open). Backtracking ensures we explore all possible balanced patterns. 📈 Learned how recursive tree exploration helps generate combinations efficiently while maintaining balance and constraints. #LeetCode #100DaysOfCode #Backtracking #Recursion #DSA #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🧩 LeetCode Challenge – Day 72 ✅ Dived into a string decoding problem today — a perfect blend of stacks, recursion, and pattern tracking. 🔗 LeetCode 394 – Decode String This challenge revolves around decoding expressions like 3[a2[c]], requiring careful handling of nested patterns and character reconstruction. It’s a great exercise in managing multiple layers of logic — keeping track of counts, substrings, and the overall decoded output step by step. 💡 Key Takeaways: • Stack-based parsing builds precision in handling nested structures. • Breaking problems into layers simplifies even the most complex logic. • Attention to detail is everything — one misplaced index can change the entire output. #Day72 #LeetCodeChallenge #100DaysOfCode #DSA #CodingJourney #ProblemSolving #Stack #Strings #Parsing #Recursion
To view or add a comment, sign in
-
-
Day 105 of 365 of Solving LeetCode Problems! ✅ Generate All Binary Strings: Given an integer n, generate all binary strings of length n representing bits. Return the strings in ascending order. Key Observations: 1) This is a classic recursion and backtracking problem — each position can either be '0' or '1'. 2) You explore both possibilities recursively until the string reaches length n. 3) The order of recursive calls ('0' first, then '1') ensures the results are in lexicographical (ascending) order. 4) Time complexity is O(2^n) since there are 2^n possible binary strings. #Recursion #Backtracking #LeetCode #DSA
To view or add a comment, sign in
-
-
I recently tackled LeetCode 2654 – Minimum Number of Operations to Make All Array Elements Equal to 1. Most solutions simulate every operation. The approach that worked for me came from stepping back and thinking mathematically: 1️⃣ If there’s already a 1 in the array, it can be spread to all other elements efficiently. 2️⃣ If no 1 exists, find the shortest subarray whose GCD is 1 – creating a 1 from that subarray is the minimal first step. 3️⃣ Once a 1 exists, the rest follows in a straightforward way. It’s a reminder that sometimes understanding the structure of a problem beats brute-force coding. And here’s a little validation: ✅ Runtime: 1ms, beats 100% of submissions ✅ Memory: 56.1MB, beats 100% of submissions For anyone doing coding challenges or preparing for interviews, focus on insights like these – they often save more time than writing extra lines of code. #ProblemSolving #Algorithms #CodingMindset #LeetCode #SoftwareEngineering
To view or add a comment, sign in
-
-
Day 36 — #100DaysOfLeetCode 🚀 Problem: Average Salary Excluding the Minimum and Maximum Salary (LeetCode 1491) ✅ Approach: Remove min & max, then calculate the average of remaining elements. ⚡ Complexity: O(n) Learning: Practiced clean logic writing and handling edge cases with arrays 🔥 #LeetCode #100DaysOfCode #DSA #Arrays #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🚀 DSA Progress – Day 120 ✅ Problem #3228: Maximum Number of Operations to Move Ones to the End 🧠 Difficulty: Medium | Topics: String, Greedy, Counting 🔍 Approach: Solved this problem using a greedy + counting strategy, focusing on how many times a '1' can cross a '0'. Step 1 (Scan the String): Traverse the string from left to right, counting how many '1's have appeared so far (count1seen). Step 2 (When You See a '0'): Every '0' contributes operations equal to the number of '1's that came before it. So whenever a '0' is found: result += count1seen Step 3 (Skip Zero Blocks): Move through continuous blocks of zeros to avoid redundant checks. Step 4 (Greedy Insight): We don’t actually move anything. We simply count how many (1 before 0) pairs exist → each pair = 1 valid operation. This makes the solution linear and optimal. 🕒 Time Complexity: O(n) — single pass through the string. 💾 Space Complexity: O(1) — only counters used. 📁 File: https://lnkd.in/gcPJcX4J 📚 Repo: https://lnkd.in/g8Cn-EwH 💡 Learned: This problem taught me that many “movement” problems can be solved by counting contributions instead of simulating actions. The key insight is recognizing that each '1' before a '0' guarantees an operation. By converting the process into a counting problem, the solution becomes elegant, readable, and highly efficient. ✅ Day 120 complete — counted binary traffic like a pro and moved those ones to the end! 🚦1️⃣➡️0️⃣🚀 #LeetCode #DSA #Python #Strings #Greedy #Counting #Binary #DailyCoding #InterviewPrep #GitHubJourney
To view or add a comment, sign in
-
💡 Day 78 of #100DaysOfCode 💡 🔹 Problem: Find Closest Number to Zero – LeetCode ✨ Approach: Traversed through the array while keeping track of the number closest to zero using absolute difference comparison. Handled ties by preferring the positive number — because even in code, positivity wins 😉 📊 Complexity Analysis: ⏱ Time Complexity: O(n) — single pass through the array 💾 Space Complexity: O(1) — no extra space used ✅ Runtime: 3 ms (Beats 44.80%) ✅ Memory: 46.87 MB 🔑 Key Insight: Even the smallest differences matter — especially when you’re finding what’s closest to zero! ⚡ #LeetCode #100DaysOfCode #DSA #ProblemSolving #CodingChallenge #JavaProgramming #AlgorithmDesign #CodeJourney #StayPositive
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