PREFACE

Solving problems that are presented in programming interviews requires a separate skillset from what you need to be a good programmer. Just like anything else, you probably won’t be very good at this when you first start, but you can develop and improve your skills just as we did. This book is the first step in that process; through this book we leverage your programming expertise to rapidly turn you into an expert at programming interviews.

Since the first edition, Programming Interviews Exposed has effectively established a new topic area of programming books, and now a multitude of websites, blogs, and forums provide advice and sample questions. With all that available, why should you invest your time and money in this book?

Our focus continues to be on teaching you the techniques and approaches you need to be successful in programming interviews. We reinforce these by illustrating the thought process that leads to the solution of each of the problems we present, and show you how to move forward when you’re stuck. These skills overlap with general coding skills, but they’re not the same; we’ve seen great coders crash and burn in programming interviews because they haven’t developed their interview skills. Early in our careers we crashed and burned a couple times ourselves, but you can avoid that by beginning your preparation with this book. Once you’ve learned the skills taught in this book you’ll continue to learn by applying them to the problems you find in other books and on the web, but this is the book you want to start with.

One thing that never changes is that to become good at solving programming interview questions, you have to do more than passively read about them: you need to practice them. You’ll get a lot more out of this book if you work out as much of each solution as you can on your own before you read about it.

Although the content of the book has expanded significantly since the first edition and the languages employed have shifted, we’ve stayed true to the goals and approach we set out then, described in the original preface, which follows.

PREFACE TO THE FIRST EDITION

If you’re like us, you don’t usually read prefaces. This one has some useful information in it, though, so we hope you’ll make an exception. If you’re still tempted to skip the preface, here’s what you really need to know: You’ll get as much out of this book as you put into it. If you read this book cover to cover, you’ll learn something, but not nearly as much as you would if you take some time trying to work through the problems on your own before you read the answers.

This book will help prepare you for the interviews you will face when seeking a job in programming, development, technical consulting, or any other field that warrants a programming interview. Programming interviews bear little resemblance to those described in traditional job-hunting and interview books. They consist almost entirely of programming problems, puzzles, and technical questions about computers. This book discusses each of the kinds of problems you are likely to encounter and illustrates how they are best approached using questions from real interviews as examples.

At this point you may be wondering who we are and what gives us the authority to write this book. We’re both recent graduates who’ve been through a lot of interviews in the past few years. We’ve interviewed for jobs ranging from technical consulting with large established companies to writing device drivers for startups. This book is based on the experiences and observations we’ve taken from those interviews—what yielded offers and what didn’t. We believe that this is the best possible basis for a book like this. Rather than give you some HR exec’s idea of how interviewing should be done or a head hunter’s impression of how it might be done, we will tell you what interviews are really like at America’s top software and computer companies and what you need to do to get the job you want.

To that end, we haven’t made up any of the questions in this book. Every last one of them has been lifted from a recent interview. The distributions of problem type and difficulty are similar to what you should expect to encounter in your interviews. We must emphasize that the problems presented in this book are a representative sample of the questions asked in interviews, not a comprehensive compilation. Reading this book straight through and memorizing the answers would completely miss the point. You may be asked some of the questions that appear in this book, but you should not expect that. A large and constantly changing body of questions is asked, and any intelligent interviewer who has seen this book will never again use any of the questions that appear here. On the other hand, interview questions encompass relatively few topic areas and types of questions, and these rarely change. If you work on learning to solve not just the specific problems we present, but the types of problems we present, you’ll be able to handle anything they throw at you in an interview.

We’ve taken a couple of steps to facilitate the objective of improving your problem-solving skills. First, where appropriate, we provide reviews of important topics before we present questions on those topics. Second, instead of merely giving answers to the problems, we illustrate the problem-solving process from beginning to solution. We’ve found that most textbooks and nearly all puzzle books take a different approach to examples: they begin with a problem, go immediately to the answer, and then explain why the answer is correct. In our experience, the result is that the reader may understand the particular answer and why it’s right, but is left with no clue as to how the author came up with that solution or how a similar problem might be solved. We hope that our step-by-step approach to solutions will address this issue, helping you to understand not only the answers but also how you arrive at the answers.

Learning by watching is never as effective as learning by doing. If you want to get the most out of this book, you will have to work out the problems yourself. We suggest the following method:

  1. After you read a problem, put the book down and try to work out the solution.
  2. If you get stuck, start reading the solution. We never blurt out the answer at the beginning, so you don’t have to worry that we’re going to give away the entire solution.
  3. Read just far enough to get the hint you need, and then put down the book and keep working.
  4. Repeat this as necessary.

The more of the solution you work out yourself, the better your understanding will be. In addition, this method closely resembles the actual interview experience, where you will have to solve the problems yourself, but the interviewer will give you hints when you get stuck.

Programming is a difficult and technical art. It would be impossible to teach everything you need to know about computers and programming in one book. Therefore, we’ve had to make some assumptions about who you are. We assume that you have a background in computers equivalent to at least the first year or two of a computer science degree. Specifically, we expect that you are comfortable with programming in C, that you’ve had some experience with object-oriented programming in C++ or perhaps Java, and that you know the fundamentals of computer architecture and computer science theory. These are effectively the minimum requirements for a general development job, so most interviewers will have similar expectations. If you find yourself lacking in any of these areas, you should seriously consider seeking more education before starting your job search and interviews.

It’s also possible that you have a great deal more computer knowledge and experience than what we’ve described as the minimum requirements. If so, you may be particularly interested in some of the more advanced topics included. However, don’t ignore the basic topics and questions, no matter how much experience you have. Interviewers tend to start with the fundamentals regardless of what’s on your résumé.

We have made every effort to ensure that all of the information in this book is correct. All of the code has been compiled and tested. Nevertheless, as you probably know all too well from your own programs, a few bugs and errors are inevitable. As we become aware of such problems, we will post corrections.

We’re confident that you’ll find this book useful in getting the job you want. We hope that you may also find it an entertaining exploration of some clever puzzles in your chosen profession. If you’d like to tell us about your reaction to our book, share your thoughts on any particular problem or topic, or provide a problem from one of your recent interviews, we’d love to hear from you.

Go find a killer job!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.126.248