Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3967868
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:46:19+00:00 2026-05-20T03:46:19+00:00

Gosh I had right now a hell of an interview. No matter how much

  • 0

Gosh I had right now a hell of an interview. No matter how much you prepare you go in and forget everything. 🙂

I thought I would share the question while it’s fresh in my mind.

1) You have 1000 objects hold as a cache. You are supposed to create the cache in an efficient manner so that the search time is very short.

Obviously they were looking for a HashSet that provides constant access time.

2) How to get the object within the cache that was least (not oldest but least) used? What to use as hashcode to achieve this, and how to get this bucket without doing any expensive searching?

I was thinking to use the timestamp of the objects as a hashcode. But how would I get the least used object without doing any search?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T03:46:20+00:00Added an answer on May 20, 2026 at 3:46 am

    My solution (I recently implemented something like this) is to have both Dictionary (Hashset) and ordered LinkedList. LinkedList will contain item and counter of access. When you want to get your item, you look into Dictionary to get node of LinkedList, then you increment counter and push node forward to keep list sorted. When you want to get least frequently used item you take head (or tail) of list.

    This makes retrieval O(1) and insertion O(n) in worst (very rare) case and O(1) best case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Gosh, I'm on here a lot... Anyways, it's in the question. I have an
gosh i know this is easy, i have done this b4... heres everything. its
Gosh, there must be a thousand different tutorials on android appwidgets and even more
I just ran a search for PHP.ini file in my C:\WAMP server and gosh!
I've not done much coding for Windows lately, and I find myself sitting at
A VERY nice to have would be if I could edit object-literals in this
This may be a dumb question. But I just received permissions to read/write to
Gosh! I hate this. Why it is so complicated? What I'm trying to do:
Html.TextBox(ParentPassword, , new { @class = required }) what the gosh darned heck is
Gosh, there are so many answered questions but i'm not sure about any of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.