Seen the Coding Interview Question Before? Say So, Then Win the Follow-Up

If you’ve seen the coding interview question before, say so in one sentence before you start. Then show what you remember. Keep it short and factual. Something like “I’ve solved this one before, so I know the standard approach” is enough. Some interviewer guides tell them to ask anyway. If they ask after you’ve rushed to a perfect answer, the truth costs more. Saying it first also changes what the round measures. A known problem no longer tells the interviewer much. So they’ll either give you a new problem or keep this one and change it. Your score then rests on how you handle that change. A memorized solution often breaks on the twist. So practice saying why the standard answer works. Below, one Android engineer handles a familiar LRU cache problem in Kotlin. You’ll see the disclosure line, the twist, the bug it exposes and a full script to adapt.

Interviewer guides say to ask if you’ve seen the coding interview question before

The question comes from interviewer checklists. The Tech Interview Handbook’s interviewer cheatsheet lists it as a step right after the problem is given. Yangshun Tay wrote the handbook. He’s a former Meta staff engineer. The page was last updated in August 2026. The site also promotes a paid front-end prep platform. The checklist item reads “Ask if the candidate has seen the question before.”

Not every interviewer asks. Some forget. Some ask halfway through. That timing is the problem. Say you hide it and code a clean answer in eight minutes. Then the interviewer asks. Now a yes sounds like a confession. A no is a lie you have to defend for the rest of the hour. Saying it at minute one avoids both.

A memorized answer shows up when the problem changes

Interviewers have a simple test for recall. They change one rule and watch what happens. In a study of cheating with ChatGPT, interviewing.io had interviewers alter well-known LeetCode problems. One interviewer said they usually add one or two twists. The goal is to catch candidates who’d heard a question before. Mike Mroczka wrote the post. He’s a former Google engineer. The page shows no date. interviewing.io sells mock interviews, so it has a stake in how prep works.

The pattern is easy to see from the interviewer’s chair. A candidate writes the standard answer fast. Then one rule changes. The candidate stalls, because they never knew why the original worked. That gap reads as memorization. You’ll still get the twist after disclosing. But the interviewer expects it then, so a stall costs less trust.

Say it in one sentence, then show what you remember

Take an Android engineer we’ll call Nadia. Her coding round is in Kotlin. The interviewer asks for an LRU cache with get and put and a fixed capacity. Nadia built this exact cache twice last month in practice. Here’s her opening.

Before I start, I’ve solved this one before. I’d use a LinkedHashMap in access order, so a read moves an entry to the end. Then I evict the eldest entry when the size goes over capacity. Happy to code that, or to take a different problem. Which is more useful for you?

That’s four sentences. The first is the disclosure. The second and third show she understands why the approach works. The last hands the choice back. There’s no apology in it, because practicing common problems is normal prep.

The interviewer swaps the problem or keeps it and adds a twist

Either reply is fine. On a swap, you lose nothing. You get a fresh problem. The interviewer also trusts what you say next. Our post on how hints are scored in a coding interview covers working through an unseen problem.

Nadia’s interviewer keeps the problem. They ask her to code the standard version quickly. She does it in about five minutes.

class LruCache<K, V>(private val capacity: Int) :
    LinkedHashMap<K, V>(16, 0.75f, true) {
    override fun removeEldestEntry(eldest: MutableMap.MutableEntry<K, V>?) =
        size > capacity
}

The true in the constructor turns on access order. Nadia says so as she types it. She runs a quick case out loud. Capacity is 2. She puts x and y, reads x, then puts z. The cache keeps x and z and drops y. That’s correct. Then the twist arrives.

The twist breaks the one-eviction rule

The interviewer says the cache holds image bytes now. Capacity is a byte budget. Each entry has a different size. Android’s own LruCache works this way. Its docs say to override sizeOf to size the cache in other units. The docs’ example measures bitmaps in bytes.

The memorized answer has a hidden limit. removeEldestEntry runs once per put. So it can remove at most one entry per insert. With equal-sized entries, one is always enough. With byte sizes, it isn’t.

We ran the naive change in Kotlin. It tracks a byte total and still evicts through removeEldestEntry. The budget is 100 bytes. Put a at 40 bytes, b at 40, then c at 90. The cache evicts a and stops. It keeps b and c at 130 bytes. That’s 30 over budget. Nothing fails or throws. A count-based test would never catch it.

The fix is a loop. Evict from the eldest end until the total fits. Android’s LruCache does the same in trimToSize. Its docs say it removes the eldest entries until the total is at or below the limit.

class ByteLru(private val maxBytes: Int) {
    private val map = LinkedHashMap<String, ByteArray>(16, 0.75f, true)
    var bytes = 0
        private set

    fun get(key: String): ByteArray? = map[key]

    fun put(key: String, value: ByteArray) {
        map.put(key, value)?.let { bytes -= it.size }
        bytes += value.size
        val it = map.entries.iterator()
        while (bytes > maxBytes && it.hasNext()) {
            val eldest = it.next()
            bytes -= eldest.value.size
            it.remove()
        }
    }
}

Run the same three puts. The loop evicts a, then b. The cache keeps c at 90 bytes. The put also handles a replaced key. It subtracts the old value’s size before adding the new one.

A full script for the twist

Here’s what Nadia says once the interviewer changes capacity to bytes. Adapt the problem, keep the shape.

OK, so capacity is now a byte total. My current version breaks on that. removeEldestEntry runs once per put, so it removes one entry at most. One large image could need several evictions.

I’ll keep the LinkedHashMap for the ordering. I’ll track a running byte total myself. After each put, I’ll evict from the eldest end in a loop until the total fits.

Let me check it. Budget 100. Put a at 40, b at 40, c at 90. The loop drops a, then b. We end with c at 90.

Two edge cases. A replaced key has to subtract the old size first. And one item bigger than the whole budget would evict everything, itself included. I’d ask whether to reject that item up front instead.

Each part of the script shows the interviewer something recall can’t

The first lines name the exact rule that breaks. Nadia doesn’t start rewriting. She explains why the old code fails. That shows she knew how it worked. A candidate who only recalled the answer can’t say which line is wrong.

The second part keeps what still holds. The access order is still right. Only the eviction step changes. That’s a small, specific edit. It shows judgment about what to reuse.

The trace uses numbers that would break the old code. Nadia picks a case where one insert needs two evictions. That’s the test her first version would fail.

The edge cases end with a question. The oversize item is a product decision. Asking about it shows she sees the requirement behind the code.

When it only looks familiar, name the part you recognize

Often you haven’t seen the exact problem. You’ve seen its pattern. Don’t claim more than that. Say which piece you recognize. For example: “This looks like an LRU cache with a size rule. I’ve built the count-based version. I haven’t done one weighted by bytes.” That tells the interviewer where the new work starts.

If the interviewer asks you directly, answer truthfully either way. A partial match deserves a partial yes. Then do what Nadia did. Explain why the known part works, so you’re ready when a rule changes. Practicing in Kotlin? Our post on the algorithm round in Android interviews covers that practice.

Leave a Comment