A lot of interviews will ask you to solve questions that relate to problem solving in computer science. While you may never see these problems in your day-to-day, a lot of companies see these problems as a way to examine your problem-solving skills, and your command of the language you most often code in. Even if you don't see these problems in an interview, they are a good way to practice converting (albeit nerdy) human problems into coded solutions (which you will definitely have to do on the job).
It may be a good idea to quickly review our whiteboarding-101 lesson before you dive into these questions.
- Find a partner.
- Partner #1 will ask the first question below, and Partner #2 will try to answer, using the whiteboard.
- After 10 minutes, Partner #1 should share at least 2 Glows and 2 Grows. Don't worry too much about syntax, focus on the big picture. For instance:
- Did they communicate their ideas well?
- Is there a more efficient way to solve the problem?
- Then Partner #2 will ask the second question below, and Partner #1 will try to answer, using the whiteboard.
- After 10 minutes, Partner #2 will share their Glows and Grows.
You have an array of integers, and you want to map them to another array that satisfies the following:
For each index of the original array, you want to replace it with the sum of every integer except the integer at that index.
Write a function for this mapping.
Write a function that can convert a decimal number into a string of its binary equivalent.
If there is extra time, how might you reverse the process?
If you know you will see this type of interview question, here are some other problems to keep your mind fresh.