Skip to content

Conversation

@priyashuu
Copy link
Contributor

This PR adds a Java implementation of an LFU Cache that supports both get() and put() operations in O(1) average time complexity.
The implementation efficiently handles eviction of the least frequently used elements, breaking ties using Least Recently Used (LRU) order.

Key Features:

  • Efficient O(1) get() and put() operations.
  • Automatically evicts the least frequently used key on capacity overflow.
  • Maintains LRU order among nodes with the same frequency.
  • Uses HashMap + LinkedHashSet for quick lookup and ordering.

Example:

Input:
image

Output:
image

Complexity Analysis:

Time Complexity: O(1) average for get() and put()

Space Complexity: O(capacity)

Files Added:

LFUCache.javaa complete implementation with comments, test example, and explanation.

@github-actions
Copy link

github-actions bot commented Oct 8, 2025

🎉 Welcome to Hacktoberfest 2025, @priyashuu! 🎃

Thank you for your first contribution to our DSA repository! Here's what happens next:

🔍 Automatic Checks

  • Code Validation: Passed
  • 🧪 Compilation Tests: Passed

📋 Next Steps

🎯 Great job! Your code compiled successfully. Maintainers @Karanjot786 and @Pradeepsingh61 will review your PR soon.

🎁 What You Get

  • 🏆 Hacktoberfest Credit: This PR counts toward your 6 PR goal for exclusive T-shirt + Tree!
  • 🌟 Hall of Fame: You'll be featured in our contributors list
  • 📚 Learning: Code review feedback from experienced developers

💡 Tips for Success

  • Follow our Contributing Guidelines
  • Add comments explaining your algorithm
  • Include time/space complexity analysis
  • Test your code before submitting

Welcome to the community! 🚀

@github-actions
Copy link

github-actions bot commented Oct 8, 2025

🤖 Automated PR Status

🔍 Code Validation

Passed - File naming and structure look good!

🧪 Compilation Tests

Passed - All code compiles successfully!

📋 Overall Status

🎉 Ready for Review - Your PR has passed all automated checks!
👥 Maintainers have been notified for review.


This comment was generated automatically. Checks will re-run when you push new commits.

@github-actions github-actions bot requested a review from Karanjot786 October 8, 2025 17:33
@Pradeepsingh61 Pradeepsingh61 merged commit d9ca800 into Pradeepsingh61:main Oct 10, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants