Programming brain teasers during job interviews is a common thing for software developers. This subject is too big to fit into a single post and there are books out there handling the same issues. I will only touch on two specific questions you might be asked by your interviewer.
I said upfront that these questions are brain teasers mainly for software developers. The list of questions is quite long but I want to highlight just two.