Caltech Rankmaniac 2012

We are trying to educate people about being CS majors and getting our site to the top of a Rankmaniac 2012 google image search

Category Archives: CS Questions

Dice Question

rankmaniac 2012

Simple puzzle for rankmaniacs ūüôā

This question is pretty simple, but I was asked it nonetheless at an interview.  You have two blank dice and you want to be able to display every day of the month using these two dice.  How would you put numbers on the dice so that some configuration of the dice show every day of the month from 01 to 31?

Tips for Rocking a CS Interview like a Rankmaniac

Hi guys,

I have just a few general tips for doing well at CS interviews. ¬†I can’t promise these will all work for you – I just know that they work for me.

  1. Buy interview books!  These handy little books include both important concepts and interesting problems.  Start reviewing them at least a week before your interviews Рthey will fill in the gaps in your knowledge and help you get in the frame of mind to answer interview questions.  Two books I recommend are Programming Interviews Exposed and Cracking the Coding Interview.  Alternatively, you can check out sites like  Wikipedia is also a good resource for algorithms.
  2. Review difficult concepts (like dynamic programming or flow networks) the night before. ¬†If you know that your job requires knowledge of systems or databases, leaf through your old textbooks on the subject. ¬†Study only briefly!¬† If you don’t already know the concepts, forcing yourself to learn them the night before will only make you stressed.
  3. Eat lightly before the interview.  This is especially important if you are nervous Рtrust me, your stomach will thank you. It will also keep your head clear and awake.
  4. Come early to the interview.  I find it helps my nervousness levels if I get acclimated to the office before I have to do my interview.
  5. Bring an extra copy of your resume.  The more copies the recruiters have, the more they will see your name and the more likely they are to remember you and hire you.
  6. At the interview, try to keep an upbeat demeanor and hide your nervousness.  This is especially true at the start of the interview before you get into the rhythm of things and your nervousness dies down.  Keeping a handle on your emotions will keep them from spiraling out of control.
  7. Don’t be afraid to chat or even make small talk with the interviewer. ¬†Many CS interviewees forget that an interview isn’t just about showing your technical skills – it’s also about demonstrating that you are a good fit for the company. ¬†A star coder who is unpleasant will be passed over by a recruiter. ¬†Note that some interviewers will not be in the mood for small talk and will want to get straight to the questions. ¬†In that case, make an extra effort to be serious and professional – small talk is off the table.
  8. Don’t be afraid to sell yourself. ¬†The point of the interview is to sell yourself. ¬†If you make a vast display of modesty, you will just be considered unqualified.
  9. Answer questions aloud. ¬†This one should be obvious. ¬†Interviewers have no idea what you are thinking. ¬†Answering questions aloud is like writing out your answers on a test – if you get stuck, at least you will still get partial credit. ¬†It is also important that the interviewer knows how you think. ¬†Silently writing the solution on a board might seem badass, but it’s not – it’s just confusing for the interviewer.
  10. Ask your interviewer questions when you are stuck. ¬†There is no shame in asking for help once you are completely stuck (you better have made a good effort first). ¬†In fact, some questions are designed to totally stump you. ¬†Interviewers want to see how you perform under pressure. ¬†Also, in a multiple question interview, it might be best to have an interviewer help you quickly through a question you can’t get so you can rock the next question. ¬†The alternative is that you waste all your time on the first question.
  11. Always have questions prepared for the end of the interview. ¬†Most interviewers will leave time for any of your questions. ¬†Don’t waste that time. ¬†I always have a few stock questions that I will ask: “What do you like most about working at company X?” “What team are you working on?” “How does part X of your infrastructure work?”.
  12. Write a short thank you note (perhaps with your resume attached) after the interview.  Remember, you want the recruiter to remember you.  This is another excuse for them to see your name.
  13. Forget about the interview ASAP!¬† Never cry over spilled milk. ¬†If you failed the interview, just forget about it – get a bite to eat, take a jog – don’t let it psych you out. ¬†If you rocked the interview, congrats! ¬†Don’t rest on your laurels though – move on and start preparing for the next interview.

Rankmaniac 2012 Interview

Shortest Unique Substrings

A few days ago I was asked to write a Java program that would return a list of the shortest unique substrings of a given string in lexicographical order.  For example, given bababba, the program returned bb.

What algorithm would you use for this and how would you implement it?

Sorting Interview Questions

Given an array of n numbers in which all the members are less than or equal to k (k<n). device an algorithm of order O(k) to find the first repeating element.


Rankmaniac 2012 – Sorting Dance

Bubble sort:¬†also known as¬†sinking sort, is a simple sorting algorithm¬†that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping¬†them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. Worst-case and average complexity both¬†–ě(n2).¬†Continue reading¬†Bubble Sort.

Insertion sort: Every repetition of insertion sort removes an element from the input data, inserting it into the correct position in the already-sorted list, until no input elements remain. Continue reading Insertion Sort

How do you think?

Some questions at interviews are just meant to get an idea of our thinking processes and our problem solving abilities. I was once asked a single question – one that I’ve heard before – and asked to give multiple different answers. Yes, there was an actual solution and I’m sure other interviewees would have known it, but I did not. So, I came up with four original answers. What answers can you come up with to the following puzzle:

You are in a room with a table in the middle of it. On the table are three lamps, two of which are always on. When you are in the room, the third light is also on. When you leave the room, the light turns off. How do you figure out which light turns off?

PS. How many computer scientists does it take to change a light bulb?

None – that’s a hardware problem.

Depth of BST

The hardest question I had was: find the depth of a binary search tree without using recursion. Anyone has good solution wants to share?

Binary Search Tree