🚀 What does this PR do?
Adds a solution for the LeetCode Daily Challenge on (Day and Date) in Java.
The solution implements a greedy approach to solve the problem "Longest Happy String", using a priority queue to manage character frequencies.
📝 Issue Reference:
Fixes issue: # (Mention the issue number this PR solves)
🔍 Checklist:
Please ensure the following before submitting your PR:
I have placed my solution in the correct folder (solutions/dayXX/).
My code follows clean coding practices and is efficient.
I have added comments in my code to explain the approach.
I have updated the README.md for the specific day with a brief explanation of my solution.
I have tested the solution on LeetCode and it works correctly.
🔧 Solution Details:
Language Used: Java
Time Complexity: O(a + b + c) where a, b, and c are the counts of characters a, b, and c.
Space Complexity: O(1) if we disregard the output string, otherwise O(a + b + c).
🌟 Additional Notes:
The approach uses a priority queue to always pick the character with the highest remaining frequency, ensuring that the string adheres to the condition that no three consecutive characters are the same.
If the top character would violate this condition, the second-most frequent character is chosen instead, and the top one is pushed back into the queue
🚀 What does this PR do? Adds a solution for the LeetCode Daily Challenge on (Day and Date) in Java. The solution implements a greedy approach to solve the problem "Longest Happy String", using a priority queue to manage character frequencies. 📝 Issue Reference: Fixes issue: # (Mention the issue number this PR solves)
🔍 Checklist: Please ensure the following before submitting your PR:
I have placed my solution in the correct folder (solutions/dayXX/). My code follows clean coding practices and is efficient. I have added comments in my code to explain the approach. I have updated the README.md for the specific day with a brief explanation of my solution. I have tested the solution on LeetCode and it works correctly. 🔧 Solution Details: Language Used: Java Time Complexity: O(a + b + c) where a, b, and c are the counts of characters a, b, and c. Space Complexity: O(1) if we disregard the output string, otherwise O(a + b + c). 🌟 Additional Notes: The approach uses a priority queue to always pick the character with the highest remaining frequency, ensuring that the string adheres to the condition that no three consecutive characters are the same. If the top character would violate this condition, the second-most frequent character is chosen instead, and the top one is pushed back into the queue