The Warden and the Three Doors

three doors puzzle

An evil warden holds you as a prisoner but offers you a chance to escape. There are 3 doors A, B, and C. Two of the doors lead to freedom and the third door leads to lifetime imprisonment, but you do not which door is what type. You are allowed to point to a door and ask the warden a single yes-no question. If you point to a door that leads to freedom, the warden does answer your question truthfully. But if you point to the door that leads to imprisonment, the warden answers your question randomly, saying either "yes" or "no" by chance. Can you figure out a way to escape the prison?

You can point towards door A and ask whether door B leads to freedom. If the warden says "YES", then you open door B. It can not lead to imprisonment because this would mean that door A leads to freedom and the warden must have told you the truth. If the warden says "NO", then you open door C. This is because either the warden lied, and then the imprisonment door is A, or he told you the truth, and then the imprisonment door is B.