Ideally, knowing the answer to the problem shouldn't be an issue. Use the fact that you know the answer as a compass to help you walk though a possible 'solution', but don't simply blurt out '42' as the answer without showing your work. Really break down the problem solving process into basic steps, and work towards the solution you already know exists.
If you don't understand the steps that were taken to arrive at the solution that you've already seen, then you really haven't already seen a solution...You've seen a hypothesized solution, and that hypothesis must be confirmed. Often times, reinforcing something you already know by laying out how you learned it is just as difficult/insightful as solving a problem you haven't seen, so that should be no trouble. If you do understand how the solution was reached, try to walk through the problem in an 'explain-it-like-I'm-5' manner, making your entire thought process obvious.
To help communicate this point a little better, let's assume we're talking about a programming domain. Lets take a really really basic programming example. You may be asked to write a program that takes in a string and reverses it without using the 'pre-existing' StringBuilder.reverse()
/StringUtils.reverse()
facilities. Maybe you've seen approaches with the string as an array of characters, and looping from the last index back to zero. You know that this is where you want to end up. But instead of just writing that down and saying 'look how smart I am, I already know this', humor them and work through the problem. Setup a test harness or a REPL and start writing test cases. First write tests for the trivial cases, like ""
and "a"
. Then test and implement cases where you have two character strings like "ab"
. Then test and implement cases where you have there character strings like "abc"
. Show them where the pattern emerges, and derive a universal solution from that pattern. Explain your reasoning each step of the way, which should be easy to do, because you already know exactly where you are going.
This need not be exclusive to programming either. The main idea here is to reflect on the solution you're already aware of, and work towards it in small steps, each time making sure it's very clear why you're making those steps. Even if you admit to the interviewer afterwards that you've already seen a similar problem before, they will likely be impressed with any sort of 'methodical' approach that explains the reasoning 'like I'm 5'.