Go to to access Wiley’s ebook EULA.

Table of Contents


Chapter 1: Before the Search

Know Yourself

Know the Market

Develop Marketable Skills

Get Things Done

Manage Your Online Profile

Chapter 2: The Job Application Process

Finding and Contacting Companies

The Interview Process

A Recruiter’s Role

Offers and Negotiation

Chapter 3: Approaches to Programming Problems

The Process

Solving the Problems

Analyzing Your Solution

Chapter 4: Linked Lists

Why Linked Lists?

Kinds of Linked List

Basic Linked List Operations

Linked List Problems

Chapter 5: Trees and Graphs



Tree and Graph Problems

Chapter 6: Arrays and Strings



Array and String Problems

Chapter 7: Recursion

Understanding Recursion

Recursion Problems

Chapter 8: Sorting

Sorting Algorithms

Sorting Problems

Chapter 9: Concurrency

Basic Thread Concepts

Concurrency Problems

Chapter 10: Object-Oriented Programming


Construction and Destruction

Object-Oriented Programming Problems

Chapter 11: Design Patterns

What Are Design Patterns?

Common Design Patterns

Design Pattern Problems

Chapter 12: Databases

Database Fundamentals

Database Problems

Chapter 13: Graphics and Bit Manipulation


Bit Manipulation

Graphics Problems

Bit Manipulation Problems

Chapter 14: Counting, Measuring, and Ordering Puzzles

Tackling Brainteasers

Brainteaser Problems

Chapter 15: Graphical and Spatial Puzzles

Draw It First

Graphical and Spatial Problems

Chapter 16: Knowledge-Based Questions



Chapter 17: Nontechnical Questions

Why Non-technical Questions?




The Technical Résumé


About the Authors

About the Technical Editors


Preface & Introduction


Preface to the First Edition


Why Programming Interviews?

How to Use this Book


End User License Agreement

Chapter 1

Before the Search

Before starting your job search, you need to prepare yourself. You shouldn’t apply for jobs without knowing what kind of job you want. Just being a good coder isn’t enough; you must understand what the market wants and how you can improve and package your own skills to make sure that the company with the job you want will want you.

Know Yourself

Stereotypes to the contrary, all programmers are not alike. Knowing what kind of programmer you are is crucial to finding the right kind of job. Although you can probably do many different kinds of programming tasks, you probably don’t find them all equally engaging. Doing something you don’t enjoy is fine on a short-term basis, but you need to be interested in and excited by what you’re doing for it to sustain you over the long term. The best programmers are passionate about their work, and you can’t truly be passionate about something that’s only moderately interesting to you.

If you’re not sure what you like or dislike, ask yourself some questions:

The preceding questions deal with different kinds of programming, but you should also consider non-programming responsibilities that might interest you and the work environment that you prefer:

Realize that there are no universal answers to these questions, and no right or wrong way to answer them. The more truthful you are in answering them, the more likely you’ll find the kind of programming job you truly enjoy.

Know the Market

Knowing what you’d like to do is great, but don’t box yourself in too narrowly. You also need to understand the current job market and how it constrains your search for the “ideal” job, especially during an economic downturn like the one that burst the Internet bubble of the late ’90s or the global real estate and banking meltdown of the late 2000s.

Basic Market Information

A number of sources of information exist about what’s hot and what’s not in the developer job market, including the following:

If you’re not in college or university, find out what languages and technologies the local institutions and your alma mater require of their computer science students; although academic needs don’t always coincide with what employers want, educational institutions try to graduate students with practical skills that employers can use.

What About Outsourcing?

Outsourcing and offshoring — contracting tasks to other companies or foreign divisions or companies — is an important part of the technical employment landscape. Outsourcing of ancillary business activities such as payroll administration and property maintenance has been around for decades. More recently, this has expanded to programming, driven by the advent of inexpensive computers, cheap long distance communication provided by the Internet, and the recognition of technically educated workforces in low-wage developing countries. There was a flurry of outsourcing, particularly offshoring, in the mid-2000s. This has become less topical in the past several years because most companies that intend to outsource have already outsourced whatever they can. In addition, the costs of offshoring have risen as wages rise in the developing world, particularly in India and China. This coupled with recognition of the hidden costs of coordination with workforces from different cultures on very different schedules have led some companies to insource roles they previously outsourced. Nevertheless, outsourcing and offshoring remain a possibility for expanding companies that think they may cut costs, as well as established companies wondering if they’re paying too much by keeping their work local.

If outsourcing (and offshoring in particular) is something that worries you, consider taking steps to avoid landing a job that might be outsourced at some point in the future. The following are some suggestions:

Of all these options, moving up the food chain is usually the best approach. The more non-programming knowledge your job requires, or the more interaction with customers, the less likely you are to be outsourced. There’s no guarantee you’ll never be outsourced, of course, or that you’ll always keep your job. Your company may shutter or downsize the project you’re working on at any point, after all, and put you back on the street. This is why developing reusable and marketable skills throughout your career is extremely important.

Develop Marketable Skills

In the appendix we discuss your résumé as a marketing tool to get you job interviews. The easiest thing to sell is something that people want, so it’s important that you have marketable skills to offer a prospective employer.

To stand out from the crowd both on paper and in the interviews you need to develop skills and accomplishments, especially if you’re entering the job market for the first time. The following are some approaches you can take:

The key is to keep learning, no matter the stage of your career. You can’t develop marketable skills overnight; they take some effort and initiative on your part but can have long-lasting effects on your career.

Get Things Done

Companies look for software developers who get things done. You may look great on paper in terms of skills and education, but credentials and knowledge don’t make products or services that a company can sell. It’s your ability to accomplish something that truly sets you apart from the other candidates.

Getting an advanced degree such as a Ph.D., becoming a trusted contributor to a widely used open source project, or carrying a product through from start to launch are all big accomplishments. But small accomplishments can be just as important, such as adding a feature to a product, making a measurable improvement to the product’s performance, starting and completing a side project, or creating a useful application for a class project. These all show that you can get things done.

Recruiters and hiring committees like to see that you have multiple accomplishments — a pattern of getting things done. This is especially true for more senior and experienced developers. You need to show those accomplishments on your résumé and your online profile. Whether your accomplishments are big or small, always be ready to talk intelligently and confidently about each one. This is incredibly important! Make sure you can clearly and succinctly describe the underlying problem and how your project solved it, even to a non-technical person. Displaying a passion for programming is always positive; clearly communicating how your passion produces products and services that other people can use makes you really stand out from the other candidates.

Manage Your Online Profile

Your online profile — everything public about you online — is just as important as your résumé. Recruiters use online profiles to find desirable candidates. Screeners use them to weed out undesirable applicants. Interviewers use them to prepare in-depth interview questions when résumés lack details.

An online profile consists of any or all these things:

The impression employers get from your online profile can affect your chances of being hired. If your résumé lists extensive experience with C# but they find a forum posting you made only 6 months ago asking how to open a file in C#, they’ll probably conclude that you’re exaggerating your experience level, putting your whole résumé into doubt. Or if they see disturbing or inflammatory material that they think you’ve authored, they may decide to pass you over for an interview, no matter how well your résumé reads or how long ago you wrote those things. No one’s proud of everything they ever did in high school or college, but those who have grown up in the post-Internet era see things follow them that they’d rather forget about, something the older generations rarely had to contend with.

At some point before you apply for a job, take a good look at your online profile. Put yourself in a company’s shoes to see how much information — good or bad — they can find about you, or link to you. If your online profile is possibly going to prevent you from being hired, take some steps to sanitize your profile. If possible, remove questionable material from the web and from the search engines.

Spend some time developing the positive aspects of your profile. This is particularly important if there’s unfavorable material about you on the web that you’re unable to remove. You may want to read a little about search engine optimization (SEO) and apply some of these techniques to get the positive aspects of your profile to appear before older, less favorable items in search results. If you don’t have a LinkedIn profile, create one, and make it as detailed as possible; if you already have one, make sure it’s up to date. Consider creating a profile on Stack Overflow or a similar Q&A site, and spend some time answering questions relating to your areas of expertise.

WARNING One caveat about updating your LinkedIn profile: By default, all your contacts are notified of your updates. Many people have learned to interpret these notifications as de facto announcements that someone is looking for a new job. That might help you get the word out, but if your contacts include people at your current company and you don’t want them to know you’re looking for a new job, disable these notifications before you make your updates.

Develop an online profile that doesn’t throw any red flags in front of the screeners and shows you in the best possible light. Finding a good job is hard enough — why make it harder?


What you do before a formal job search is critical to finding the right kind of job. With that in mind, you should consider the following things:

Once you’ve worked through all these points, you’re ready to begin your job search.

Chapter 2

The Job Application Process

Interviewing and recruiting procedures are similar at most tech companies, so the more prepared you are for what you will encounter, the more successful you will be. This chapter familiarizes you with the entire job-search process, from contacting companies to starting your new job, so you won’t need to write off your first few application attempts as learning experiences. Hiring procedures at technical companies are often substantially different from those followed by more traditional firms, so you may find this information useful even if you’ve spent some time in the working world.

Finding and Contacting Companies

The first step to getting a job is to find and make contact with companies you’re interested in working for. Although referrals are the best way to land a job, you can also work with headhunters or contact a company directly.

Finding Companies

You can better target your search if you know which companies you’re most interested in working for. Big companies are easy to find — you can probably name a dozen national and international tech companies off the top of your head. You can identify candidate medium-sized (as well as large) companies through articles in trade and local business press. Many magazines and newspapers regularly compile lists of successful companies and rankings of the best places to work. (Take these rankings with a grain of salt: There’s often a lot of variation in quality of work life across large companies.) Most companies of this size also advertise at least some of their job openings on online job boards; these postings can help you identify companies to investigate even if the specific job posted isn’t right for you.

Small companies, especially early-stage startups, can be much more challenging to find. Often these companies are too small, too new, or too secretive to get much press. They may lack the resources to advertise their openings beyond their own website, which you can’t find unless you know the name of the company. One good way to find these companies is asking friends and acquaintances if they know of startups that are hiring. Another technique is to use online social networks. You can use some sites, such as LinkedIn, to search for people by profession within a region. Most people on these sites list the name of their company, so you can build a list of companies in a particular region by going through the results of this search. This can be laborious, but part of the payoff is that if you can’t find these companies any other way, neither can anyone else, so you’re likely to be competing with fewer applicants.

Getting Referrals

Referrals are the best way to find a job. Tell all your friends about what kind of job you’re looking for. Even if they don’t work for the kinds of companies that might hire you, they may know people who do. Coming from “Susan’s friend” or “Bill’s neighbor,” your résumé is sure to receive more careful consideration than the hundreds (or thousands) of anonymous résumés that come flooding in from online postings, job fairs, and other recruitment activities. Be sure to use your social networks, both real and virtual, to identify potential job opportunities.

Don’t feel you’re imposing on your friends and acquaintances. Companies often reward employees with big bonuses — as much as several thousand dollars — for successful referrals of talented software engineers. Your friends have a financial incentive to submit as many résumés as possible! (This is why referral bonuses are paid only after the referred person has been hired and has started working for the company.)

After you have a contact at a company, it’s up to you to make the most of it. Your approach depends on how well you know the contact.

If the contact is not a close friend, e-mail the person to arrange a time to speak. When you speak to the person, ask about the company and the work environment. Then ask about any existing job openings. The person might not know of any — many employees know only about job openings in their immediate workgroup — but if you know jobs are available, point the person to the job listings. Explain why you’d be a good match for one of those openings. Then ask the person to submit your résumé. Before you end your conversation, always thank people for their time.

If the contacts are close friends, you can be more casual and just ask about job openings and if they’d refer you.

The best referrals are from people who have worked with you before. A current employee who vouches for your skills and accomplishments is the strongest type of referral. That’s why you need to keep track of former co-workers — you might want to work with them again one day.

Working with Headhunters

Particularly when labor markets are tight, some firms use outside recruiters known as headhunters to help them find candidates. In addition, you may find it useful to seek out a headhunter and provide her with your information.

If you list yourself with a headhunter, she can assist you with your job search and call you when she learns of an opening that matches your skill set. It may take a while, so don’t be discouraged.

Some headhunters are more helpful than others, so ask around to see if anyone you know has recommendations. If you can’t locate a headhunter this way, you can search the web for headhunters, recruiters, or staffing services. You can check out a prospective headhunter by asking for references, but be aware that headhunters deal with so many people that even those who frequently do a poor job probably have 5 or 10 satisfied clients who serve as references.

When you work with headhunters, you must understand their motivation: headhunters are paid only when an applicant they’ve referred is hired. It is therefore in a headhunter’s interest to put as many people as possible into as many jobs as possible as quickly as possible. A headhunter has no financial incentive to find you the best possible job — or to find a company the best possible applicant, for that matter. If you recognize that a headhunter is in business for the purpose of making a living and not for the purpose of helping you, you are less likely to be surprised or disappointed by your experiences. This is not to suggest that headhunters are bad people or that as a rule they take advantage of applicants or companies. Headhunters can be helpful and useful, but you must not expect them to look out for your interests above their own.

When you get a potential lead from a headhunter, she will usually send you a job description and a vague description of the type of company but not the name of the company. This is to make sure that if you apply for the job, you do it through the headhunter so that she gets her commission. It’s unethical to independently apply for a job that comes to you through a headhunter, but sometimes you might like to have more information about the job or company before you proceed. For example, you may determine that it’s a job you’ve already applied for, or at a location that would involve too long of a commute. The job description that the headhunter sends you is often copied verbatim from the company’s website so by pasting it into your favorite search engine you can often find the original job listing.

Some companies don’t work with headhunters in any capacity, so don’t limit yourself by conducting your entire job search through a headhunter. As a corollary of this, avoid working with any headhunter who insists on being your exclusive representative. Finally, be aware that “headhunter” is a widely used term by people outside of this profession, but considered pejorative by most of the people who do this work, so it’s best not to use the word “headhunter” when you speak to one of them.

Contacting the Company Directly

You can also try contacting companies directly. The Internet is the best medium for this approach. Most companies’ web pages have instructions for submitting résumés. If the website lists specific openings, read through them and submit your résumé specifically for the openings that interest you. If you don’t have a contact within the company, it’s best to look for specific job openings: In many companies, résumés targeted at a specific job opportunity are forwarded directly to the hiring manager, whereas those that don’t mention a specific opening languish in the human resources database. A tech-oriented job site is a good place to start your search if you don’t have a specific company already in mind.

If a site doesn’t provide any directions for submitting your résumé, look for an e-mail address to which you can send it. Send your résumé as both plain text in the body of the e-mail (so the recipient can read it without having to do any work) and, unless there are instructions to the contrary, as an attached file so that the recipient can print a copy. A PDF file is ideal; otherwise, attach a Microsoft Word file. Do not send a file in any other format unless specifically requested. Be sure to convert the file so that it can be read by older versions of Word, and scan it with an antivirus program (you can easily do this by mailing the resume to yourself as an attachment) to be absolutely certain that your résumé isn’t carrying any macro viruses.

Approaching a company directly like this is a bit of a long shot, especially when the résumé is sent to a generic human resources e-mail address. Many companies use automated screening software to filter incoming résumés, so if your résumé lacks the right buzzwords, a human probably won’t even see it. Consult the appendix for tips to get your résumé past automated screeners. With a good résumé in hand it takes so little time and effort to apply that you have nothing to lose.

Job Fairs

Job fairs are an easy way to learn about and make contact with a lot of companies without much effort. Your chances of success with any one particular company at a job fair are low because each company sees so many applicants. However, given the number of companies at a job fair, your overall odds may still be favorable. If you collect business cards at the job fair and follow up with people afterward, you can separate yourself from the rest of the job fair crowd.

In addition, if they are available to you, college career centers, alumni organizations, and professional associations can also be helpful in finding jobs.

The Interview Process

If someone is sufficiently impressed by your résumé to want to talk to you, the next step is one or more screening interviews, usually followed by an on-site interview. Here, we prepare you for the stages of the interview process and help you dress for success.

Screening Interviews

Screening interviews are usually conducted by phone and last anywhere from 15 minutes to an hour. You should take the interview in a quiet room with no distractions and keep pen and paper handy to take notes. Screening interviews may also take place on the spot at a job fair or on campus as part of a college recruiting process.

The initial screening interview is with a company recruiter or human resources representative. The recruiter wants to make sure that you’re interested in doing the job the company is hiring for, that you have the skills needed for the position, and that you’re willing to accept any logistical requirements of the position, such as relocation or travel.

If you make it past the recruiter, there’s normally a second screening interview in which a technical person asks you a few knowledge-based questions. These questions are designed to eliminate applicants who have inflated their résumés or are weak in skills that are key to the position. During the technical interview you may be asked to write some code using some kind of cloud-based document-sharing tool such as Google Docs. This gives the interviewer a firsthand look at your coding skills.

You should treat the phone interview as seriously as an on-site interview. It is an interview.

If the feedback from the technical interviewer is positive, the recruiter will get back to you, usually within a week, to schedule an on-site interview at the company’s office.

On-Site Interviews

Your performance in on-site interviews is the biggest factor in determining whether you get an offer. These interviews consist mostly of a variety of technical questions: problems requiring you to implement a simple program or function; questions that test your knowledge of computers, languages, and programming; and sometimes even mathematics and logic puzzles. The majority of this book focuses on helping you answer these questions to succeed in your interviews.

Your on-site interviews usually last either a half day or a full day and typically consist of three to six interviews of 30 to 60 minutes each. Arrive early and well rested at the company’s office, and take a restroom break if at all possible before any of the interviewing starts. Turn off any phones or pagers you carry. Under no circumstances should you interrupt your interview to read or answer a text, page, or call. You’ll likely be greeted by either the recruiter you’ve been dealing with or the hiring manager. You may get an informal tour before the actual interviewing starts, which is a good way to see what the working conditions are like at that location.

Your interviewers may be the members of the team you’ll work with if you are hired, or they may be engineers chosen at random from other groups within the company. Most companies have a rule that any interviewer can block an applicant from being hired, so all your interviews are important. Sometimes you may interview with two separate teams on the same day. Usually each group you interview with makes a separate decision about giving you an offer.

The company usually takes you out for lunch midway through your interview day. A free lunch at a nice restaurant or even at the company cafeteria is certainly enjoyable, but don’t let your guard down completely. If you make a negative impression at lunch, you may lose your offer. Be polite, and avoid alcohol and messy foods. These general guidelines apply to all company outings, including evening recruiting activities. Moderate drinking is acceptable during evening outings, but show restraint. Getting drunk isn’t likely to improve your chances to get an offer.

At the end of the day, you may meet with the boss; if he or she spends a lot of time trying to sell you on working for the company, it’s a pretty strong indication that you’ve done well in your interviews and an offer will follow.


Job applicants traditionally wear suits to interviews. Most tech companies, though, are business casual — or even just casual. The running joke at some of these companies is that the only people who wear suits are job candidates and salespeople.

This is one area in which it’s critical to do some research. It’s probably not to your advantage to wear a suit if nobody else at the company is wearing them, not even the salespeople. On the other hand, if you wear jeans and a T-shirt, interviewers may feel you’re not showing sufficient respect or seriousness, even though they may be wearing jeans. Ask around to see what’s appropriate for the company. Expectations for dress vary by location and nature of business. For example, programmers working for a bank or brokerage may be expected to wear suits. You should aim to dress as well as or slightly more formally than you would be expected to dress for the job you’re interviewing for.

In general, though, a suit or even a jacket and tie is overkill for most technical job interviews. A standard technical interviewing outfit for men consists of non-denim cotton pants, a collared shirt, and loafers (no sneakers or sandals). Women can dress similarly to men. No matter what your sex, go light on the perfume or cologne.

A Recruiter’s Role

Your interviews and offer are usually coordinated by a company recruiter or human resources representative. The recruiter is responsible for the scheduling and logistical aspects of your interview, including reimbursing you for travel or lodging expenses. Recruiters aren’t usually involved in the hiring decision but may pass on information about you to those who are. They are also usually the ones who call you back about your offer and handle compensation negotiations.

Recruiters are usually good at what they do. The vast majority of recruiters are honorable people deserving of your respect and courtesy. Nevertheless, don’t let their friendliness fool you into thinking that their job is to help you; their job is to get you to sign with their company as quickly as possible for as little money as possible. As with headhunters, you need to understand the position recruiters are in so that you understand how they behave:

Offers and Negotiation

When you get an offer, you’ve made it through the hardest part: You now have a job, if you want it. However, the game isn’t over yet. You’re looking for a job because you need to make money; how you play the end game largely determines how much you get.

When your recruiter or hiring manager makes you an offer, she may also tell you how much the company plans to pay you. Perhaps a more common practice, though, is for the recruiter or hiring manager to tell you that the company would like to hire you and ask you how much you want to make. Answering this question is covered in detail in Chapter 17.

After you’ve been given a specific offer that includes details about salary, signing bonus, and stock options, you need to decide whether you’re satisfied with it. This shouldn’t be a snap decision — never accept an offer on the spot. Always spend at least a day thinking about important decisions such as this; it’s surprising how much can change in a day.

Dealing with Recruiter Pressures

Recruiters often employ a variety of high-pressure tactics to get you to accept offers quickly. They may tell you that you must accept the offer within a few days if you want the job, or they may offer you an exploding signing bonus: a signing bonus that decreases by a fixed amount each day. Don’t let this bullying rush your decision. If the company wants you (and it probably does if it made you an offer), these limits and terms are negotiable, even when a recruiter claims they aren’t. You may have to go over the recruiter’s head and talk to your hiring manager if the recruiter refuses to be flexible. If these conditions are non-negotiable, you probably don’t want to work for a rigid company full of bullies anyway.

Negotiating Your Salary

If, after careful consideration, the offer meets or exceeds your expectations, you’re all set. On the other hand, if you’re not completely happy with your offer, you should try to negotiate. All too often, applicants assume that offers are non-negotiable and reject offers without negotiation or accept offers they’re not pleased with. Almost every offer is negotiable to some extent.

You should never reject an offer for monetary reasons without trying to negotiate. When you negotiate an offer that you would otherwise reject, you hold the ultimate high card. You’re ready to walk, so you have nothing to lose.

Even when an offer is in the range you were expecting, it’s often worthwhile to negotiate. As long as you are respectful and truthful in your negotiations and your requests are reasonable, you’ll almost never lose an offer just because you tried to negotiate it. In the worst case, the company refuses to change the offer, and you’re no worse off than before you tried to negotiate.

If you decide to negotiate your compensation package, here’s how you do it:

Many people find negotiation uncomfortable, especially when dealing with professional recruiters who do it every day. It’s not uncommon for someone to accept an offer as close enough just to avoid having to negotiate. If you feel this way about negotiation, try looking at it this way: You rarely have anything to lose, and even modest success in negotiation can be rewarding. If it takes you a 30-minute phone call to get your offer increased by $3,000, you’ve made $6,000 per hour. Even lawyers aren’t paid that much.

Remember that the best time to get more money is before you accept the job. When you’re an employee, the company holds all the power.

Accepting and Rejecting Offers

At some point, your negotiations will be complete, and you will be ready to accept an offer. After you inform a company you’re accepting its offer, be sure to keep in touch to coordinate start dates and paperwork. The company may do a background check on you at this point to verify your identity and your credentials.