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
Solved #50DaysOfLeetCodeChallenge: Sort characters by frequency
More Relevant Posts
-
Day 23 of #50DaysOfCode – Java 💻 Today’s challenge was to check whether a number is a Perfect Number. A Perfect Number is a number that is equal to the sum of all its positive divisors (excluding itself). Example: 6 → 1 + 2 + 3 = 6 28 → 1 + 2 + 4 + 7 + 14 = 28 This problem helped me strengthen my understanding of loops, conditions, and mathematical logic 🔍✨ #Java #CodingChallenge #50DaysOfCode #LearnToCode #ProgrammingBasics #LogicBuilding #CodeDaily #ProblemSolving
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 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
To view or add a comment, sign in
-
-
🌟 Day 86 of #100DaysOfCodingChallenge 🌟 🚀 Problem: 561. Array Partition 💻 Language: Java Today’s challenge was about maximizing the sum of the minimum values in n pairs formed from an array of 2n integers. 🧩 Approach: 1️⃣ Sort the array in ascending order. 2️⃣ Take every alternate element (starting from index 0). 3️⃣ Add them up — this gives the maximum possible sum of mins in all pairs. 🧠 Key Insight: When the array is sorted, pairing adjacent elements ensures the smallest numbers are always matched optimally, leading to the maximum possible result. 📊 Example: Input → [1,4,3,2] Sorted → [1,2,3,4] Pairs → (1,2), (3,4) Output → 4 ✅ ✨ Learning: Sometimes the simplest approach — sorting and selecting — can yield the most optimal result! #Day86 #LeetCode #Java #100DaysOfCode #CodingChallenge #ProblemSolving #ArrayPartition #DSA #WomenInTech #SathyabamaUniversity
To view or add a comment, sign in
-
-
Day 22 of #50DaysOfCode – Java 🚀 Today’s challenge was to check whether a number is a Strong Number 💪 A Strong Number is a number in which the sum of the factorials of each digit equals the original number. Example: 145 → 1! + 4! + 5! = 145 ✔️ (Strong Number) This problem helped me practice: ✔️ Using loops inside loops ✔️ Calculating factorials ✔️ Strengthening logic-building skills #Java #CodingChallenge #50DaysOfCode #LogicBuilding #ProgrammingBasics #LearnToCode #DailyCoding #StrongNumber
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
-
-
🚀 Day 13: Journey in Java – Recursion What is Recursion? Recursion is a process where a method calls itself to solve a problem step by step. It continues calling itself until it reaches a base condition, which stops the recursion. Without a base condition, the program will keep calling itself and end up in a StackOverflowError ⚠️. 🧠 Simple Explanation: Think of a box of products — you keep adding products one by one. If you keep adding without stopping, the box will overflow. Similarly, in recursion, we must define a condition (the base case) to stop at the right time. ✅ In short: Recursion = Method calling itself until a stopping condition is met. 10000 Coders #Java #Recursion #LearningJourney #JavaDeveloper #Day13 #SoftwareDevelopment #LearningEveryday
To view or add a comment, sign in
-
-
🌟 Day 93 of #100DaysOfCodingChallenge 🌟 🔹 Problem: 442. Find All Duplicates in an Array 🔹 Platform: LeetCode 🔹 Language: Java 🔹 Difficulty Level: Medium 🧩 Problem Statement: Given an integer array nums containing numbers from 1 to n, find all the elements that appear twice in the array. 💡 Intuition: To identify duplicates efficiently, I used two HashSets — one to store visited elements and another to store duplicates when an element is already seen. This method makes the solution concise and easy to understand while maintaining good performance. ✅ Time Complexity: O(n) ✅ Space Complexity: O(n) 🚀 Key Takeaway: Sometimes, clarity and simplicity in code matter more than optimization — this approach is easy to implement and perfectly suitable for most scenarios. #Day93 #LeetCode #100DaysOfCode #Java #ProblemSolving #CodingChallenge #DSA #LearnByCoding #WomenInTech
To view or add a comment, sign in
-
-
🌟 Day 22 of #JavaLearning 🌟 Today, I solved ArrayList practice problems covering beginner to advanced topics. 💡 ArrayList in Java: It is a predefined class introduced in Java 1.2. Part of the java.util package. Allows null values. Duplicate values are allowed. Insertion order is maintained. I practiced operations like: Adding, accessing, updating, and removing elements Sorting, reversing, and merging lists Finding max/min, frequency, and duplicates Converting between arrays and ArrayLists Retaining common elements and filtering with conditions 10000 Coders #Java #Collections #ArrayList #100DaysOfCoding #Day22
To view or add a comment, sign in
-
Day 20 of #50DaysOfCode – Java Today’s task: Find the sum of all odd digits in a given number! 🔢 A simple yet logical exercise that helps strengthen your understanding of loops, conditionals, and digit manipulation. 💡 👉 This program takes a number as input and calculates the total of its odd digits using a while loop and the modulus operator. #Java #CodingChallenge #50DaysOfCode #LearnToCode #ProgrammingBasics #LogicBuilding #CodeEveryday #JavaProgramming
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