Day 46 of #100DaysOfLeetCode Challenge 🚀Today’s Problem: Remove Duplicate Letters (LeetCode - Medium) Language: Java In this problem, the goal is to remove duplicate letters from a string such that every letter appears once and the result is the smallest lexicographical order possible. Concepts Covered: Stack for maintaining order Greedy approach for smallest lexicographical sequence Tracking last occurrence index of each character Boolean array to keep track of visited characters Key Takeaways: Understanding when to remove elements from the stack is crucial for optimal ordering. The combination of stack + greedy ensures both uniqueness and lexicographical minimality. #100DaysOfCode #LeetCode #Java #ProblemSolving #CodingChallenge #DSA #DevelopersJourney
Solved Remove Duplicate Letters problem in Java using stack and greedy approach
More Relevant Posts
-
🚀 Day 26 of 100 Days of LeetCode 📘 Problem: Search a 2D Matrix 💻 Language: Java ✅ Status: Accepted — Runtime: ⚡ 0 ms (Beats 100%) Today’s problem focused on searching efficiently within a 2D matrix — a great exercise for understanding nested loops, traversal logic, and time optimization. While this version used a simple brute-force approach, it served as a good refresher on matrix iteration patterns before moving on to more optimized binary search techniques in 2D grids. ✨ Key Learnings: Matrix traversal can be intuitive when visualized 🔢 Always consider both brute-force and optimized approaches — understanding both is key to depth of knowledge Writing clean, readable code matters as much as optimizing it Each problem solved is another small brick in the foundation of strong problem-solving skills 💪 #Day26 #100DaysOfCode #LeetCode #Java #ProblemSolving #DSA #CodingJourney #SoftwareDevelopment #Matrix #KeepLearning #CodeEveryday
To view or add a comment, sign in
-
-
Day 45 of #50DaysOfLeetCodeChallenge Today's Problem: Sort characters in a string by their frequency. -Approach: First, I counted the frequency of each character in the string using a HashMap. Then, I used a Max-Heap (PriorityQueue) to sort the characters based on their frequencies. Finally, I built the result string by repeating each character according to its count. It was interesting to see how Java’s collections can simplify what seems like a complex problem at first! -Key Takeaways: HashMaps make counting elements fast and easy. PriorityQueue (Max-Heap) is perfect when we need to sort dynamically by priority. #Java #DSA #ProblemSolving #CodingJourney #50Days #CodeToLearn
To view or add a comment, sign in
-
-
Another late-night success Solved a tricky binary search + sliding window problem efficiently in Java, optimizing power distribution logic in minimal runtime. 📊 Runtime: 31 ms 💡 Beats 89.29% of Java submissions 🧩 Concepts used: Binary Search, Prefix Sum, Sliding Window Each accepted solution reminds me that writing clean, efficient code isn’t just about passing tests — it’s about thinking like the system itself. #Java #LeetCode #ProblemSolving #Algorithms #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 29 of 100 Days of LeetCode 📘 Problem: Combination Sum 💻 Language: Java ✅ Status: Accepted — Runtime ⚡ 2 ms (Beats 86%) Today’s problem was all about backtracking — exploring all possible combinations to reach a target sum. It’s a perfect blend of recursion, decision-making, and pruning unnecessary paths 🧠 ✨ Key Learnings: Backtracking is like exploring a maze — try, backtrack, and try again until you find the exit 🌀 Each recursive call represents a “choice point” — include or skip the element Clean recursion with controlled base cases leads to clarity and precision This problem reminded me how persistence works in both code and life: 💬 “Sometimes, the path to the solution is not straightforward — you just need to keep exploring.” #Day29 #100DaysOfCode #LeetCode #Java #Backtracking #Recursion #DSA #ProblemSolving #CodingJourney #SoftwareDevelopment #KeepLearning #CodeEveryday
To view or add a comment, sign in
-
-
“𝒀𝒆𝒉 𝒐𝒓𝒊𝒈𝒊𝒏𝒂𝒍 𝒘𝒂𝒍𝒂 𝒌𝒚𝒖𝒏 𝒃𝒂𝒅𝒂𝒍 𝒈𝒂𝒚𝒂?” If you’ve ever asked that while cloning objects in Java — this post is for you! Here’s a simple visual breakdown of Shallow vs Deep Copy. #Java #LearningEveryday #SoftwareDevelopment #Coding
To view or add a comment, sign in
-
🚀 Day 27 of 100 Days of LeetCode 📘 Problem: Generate Parentheses 💻 Language: Java ✅ Status: Accepted — Runtime: ⚡ 0 ms (Beats 100%) Today’s challenge focused on backtracking, one of the most elegant and powerful problem-solving techniques in DSA. The task was to generate all possible valid combinations of parentheses — a perfect test of recursion and logical constraints 🧩 ✨ Key Learnings: Backtracking is about exploring all possibilities, then undoing choices when needed 🔄 Understanding base cases clearly makes recursion much easier Clean recursive structures lead to elegant and efficient solutions This problem reinforced one important principle — 🧠 “Sometimes, going back is the only way to move forward — both in code and in life.” #Day27 #100DaysOfCode #LeetCode #Java #Backtracking #Recursion #ProblemSolving #CodingJourney #DSA #SoftwareDevelopment #KeepLearning #CodeEveryday
To view or add a comment, sign in
-
-
🚀 Day 34 of 100 Days of LeetCode 📘 Problem: Merge Intervals 💻 Language: Java ✅ Status: Accepted — Runtime ⚡ 8 ms (Beats 86%) Today’s challenge was all about mastering interval merging, an essential concept for solving scheduling and range-based problems efficiently 🧩 By sorting intervals and carefully merging overlapping ones, I learned how crucial boundaries and comparisons are — both in coding and in life. ✨ Key Learnings: Sorting simplifies complex interval logic Smart use of conditions avoids unnecessary comparisons Handling edge cases builds precision thinking ⚙️ 💬 “Merge where it makes sense — in code and in life.” #Day34 #100DaysOfCode #LeetCode #Java #DSA #ProblemSolving #Algorithms #CodingJourney #SoftwareDevelopment #KeepLearning #CodeEveryday
To view or add a comment, sign in
-
-
🚀 Day 20 of #100DaysOfLeetCode 💡 Problem: Gray Code Today’s challenge was all about generating the Gray Code sequence, a fascinating binary numbering system where only one bit changes between consecutive numbers. 🧠 Concept: Gray codes are widely used in digital communication and error correction, ensuring minimal transition errors between binary states. 🔍 Key takeaway: Bit manipulation + recursion = elegant solution ✨ 💻 Languages used: Java #LeetCode #100DaysOfCode #ProblemSolving #CodingChallenge #Java #GrayCode #DSA #BitManipulation
To view or add a comment, sign in
-
-
🚀Day 97/100 #100DaysOfLeetCode 👩💻Problem: Valid Square✅ 💻Language: Java 💡Approach: To check if four given points form a valid square, I calculated all six pairwise distances between the points. 🔹A valid square must have two distinct distances — 4 equal smaller sides and 2 equal longer diagonals. 🔹Used a HashMap to count occurrences of each distance. 🔹If the map has exactly two distinct non-zero distances and the smaller one appears 4 times while the larger appears 2 times, it’s a square! 🧠Key Takeaways: 🔹Strengthened understanding of geometry-based problems. 🔹Reinforced hashing techniques for quick frequency checks. 🔹Improved logic for pairwise comparison and distance calculation. ⚙️Performance: ⏱️Runtime: 2 ms (Beats 27.27%) 💾Memory: 41.91 MB (Beats 22.03%) #100DaysOfLeetCode #Java #CodingChallenge #LeetCode #ProblemSolving #CodingChallenge
To view or add a comment, sign in
-
-
Day 89 of #100DaysOfCode Solved Find Numbers with Even Number of Digits in Java 🔢 Approach The goal of this problem was to count how many integers in a given array have an even number of digits. I implemented two methods: findNumbers(int[] nums): This is the main function that iterates through every number in the input array nums. isEvenOrOdd(int n): This helper function takes an integer and determines if its digit count is even or odd. Inside the helper function, I used a while loop to count the digits: I initialized a count to 0. The loop continues as long as $n > 0$. In each iteration, I increment count and then perform integer division by 10 (n = n / 10) to remove the least significant digit. Finally, I return true if the total count of digits is even (count \% 2 == 0). This efficient, digit-by-digit checking approach resulted in a strong performance, beating 98.90% of other submissions. #Java #100DaysOfCode #LeetCode #CodingChallenge #Algorithms #Array #ProblemSolving #Optimization
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