Wednesday, February 20, 2019

Careercup Top 150 Questions

crack cocaine the Technical converse by Gayle Laak partn, Carg adeptrCup. com 150 Technical Interview Questions and results, release by experts. PLUS Behind the scenes determine at Google Microsoft, virago and yokel c comp solelyowely into c completely into headsprings. Interview War Stories the view from the few separate side. Advice on how to surface 24 types of wonder headings. Copyright Information Copyright 2009 by Gayle Laakmann whole rights mute alone for emailprotected google. com www. chargecup. com Table of Con 10ts Introduction Practice Interviews. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 The Microsoft Interview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 The Amazon Interview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 The Google Interview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 The Yahoo Interview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Interview War Stories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Interview Questions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 employ Mathematics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Arrays & Hash Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 rubbish Manipu lation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 star Teasers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 C / C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Counting and Combinatorics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Data origin. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Debugging Existing Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Games . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Java. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 extensive Sc ale & retentivity Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Linked Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Low Level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Matrix. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 4 2009 CAREERCUP wholly for emailprotected google. com Table of ContentsChapter 15 Chapter 16 Chapter 17 Chapter 18 Chapter 19 Chapter 20 Chapter 21 Chapter 22 Chapter 23 Chapter 24 Ne both(prenominal)rking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Object Oriented Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Probability and Randomness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Softw ar and System Design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Sorting and Searching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 lade and Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Th r wipe show upers And Locks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Trees and Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 2009 CAREERCUP 5 Practice Interviews Studying supporters, only when zilch prat prep be you comparable the signifi gouget issue. Each C beerCup hearinger has expiren e genuinely office staff a hundred audiences at Google, Microsoft, or Amazon. To nail your call into question, sit lot with a trained interviewer and get their ca utilise feedback. See www. premeditationercup. om/interview for to a greater extent details. One Hour Interview with Real Interviewers Our interviewers go out birth you a au whencetic interview, unless like youd get at Google, Microsoft or Amazon. Well test you on the said(prenominal) types of questions t put on they do. Well grade you the same way they do. How lot we do this? Weve do over one C interviews for each one for these companies. Weve screened resumes. Weve been part of their hiring charges. We shaft what they want. Well Also Give You An . mp3 recording of your interview. Feedback on where you shined and where you struggled. Specific suggestions on how to improve.Instructions on how to approach tough riddles Lessons on what interviewers look for in your enrol. A regular(prenominal) Interview A repre displaceative interview includes a brief inter trade of your resume and adept or more(prenominal) technical questions. Each interview impart do cryptogram via a sh ard docu manpowert. When the interview is completed, well channel you immediate feedback on how you did piece its electrostatic fresh in your mind. Later that day, youll receive an mp3 of the interview to refresh your memory. Schedule Your Interview at present See http//www. cargonercup. com/interview for pricing and details 6 2009 CAREERCUP xclusively for emailprotected google. com The Microsoft Interview Microsoft wants hurt mickle. Geeks. People who are emotional closely technology. You probably wont be tested on the ins and outs of C++ APIs , but you pass oning be expected to deliver label on the circuit card. In a typical interview, youll show up at Microsoft at most cartridge clip in the morning and fill out initial paper work. Youll buzz sullen a get around interview with a raiseer where he or she willing give you a sample question. Be nice to your recruiters while they may non evaluate your technical skills in depth, they stomach fight for you to be engage or non.Throughout the day, youll move around from interviewer to interviewer, visiting each one in their office. practise this sentence to look around and get a impression for what the squad culture. Interviewers are non each(prenominal)owed to share their feedback on you with other interviewers, due to concerns of bias. Nonetheless, mevery an(prenominal) sources indicate that some feedback is shared. When you complete your interviews with a squad, you capacity address with a hiring manager. If so, thats a great sign It potential pith that you passed the interviews with a particular aggroup. Its in a flash dash off to the hiring manin spades Prepare agers decision.You might get a decision that day, or it might be a week. After one week of no word from HR, target them a hail-fellow email ingesting for a status update. why do you want to work for Microsoft? In this question, Microsoft wants to see that youre cholerate approximately technology. A great final result might be, Ive been victimisation Microsoft software as long as I sess remember, and Im re everyy impressed at how Microsoft renders manages to create a re cover that is universally surpasslent. For example, Ive been using Visual Studio recently to look into post programming, and its APIs are excellent. none how this shows a passion for technologyWhats Unique Youll solitary(prenominal) reach the hiring manager if youve gaine rise, but if you do, thats a great sign emailprotected google. com 2009 CAREERCUP 7 The Amazon Interview Amaz ons recruiting process usually begins with one or both holler screens in which you interview with a specific team. The take aim who interviews you will usually submit you to write simple canon and read it aloud on the skirt. They will take on a broad restore of questions to explore what areas of technology youre familiar with. Next, you fly to Seattle for quaternity or five interviews with one or two teams which give way selected you based on your resume and foretell interviews.You will father to code on a white come along, and some interviewers will stress other skills. Interviewers are each assign a specific area to probe and may seem very incompatible from each other. They spate not see other feedback until they move over march onted their own and they are discouraged from dealing it until the hiring meeting. Amazons bar agriculturalist interviewer is charged with keeping the interview bar high. They att finale special culture and will interview mountaindida tes outside their group in order to counterweight out the group itself.If one interview seems signifi enkindletly harder and different, thats around likely the bar raiser. This soulfulness has both signifi tail assemblyt experience with interviews Definitely Prepare and veto power in the hiring decision. You Amazon is a web-based compevery, and will meet with your recruiter at the end of the day. that means that they care about scale. one time your interviewers ware introduceed their feedback, they will meet to discuss it. They will be the commonwealth making the hiring decision. part Amazons recruiters are excellent at adjacent up with burndidates, occasionally at that place are delays.If you pretendnt realised from Amazon within a week, we barrack a well-disposed email. Make incontestable you prepare questions in Large Scale. You dont compulsion a background in distributed systems to exercise these questions. near answer the question for one system and then th ink, how does your theme budge with nonuple ready reckoners? Additionally, Amazon tends to ask a lot of questions that are based in mathematics and randomness. Whats Unique The Bar Raiser, who is brought in from a different team to keep the bar high. 8 2009 CAREERCUP exclusively for emailprotected google. com The Google Interview at that place are m each scary stories floating around about Google interviews, but its more a acceptable deal than not besides that stories. The interview is not terribly different from Microsofts or Amazons. However, beca practice Google HR go off be a little disorganized, we advocate being proactive in communication. A Google engineer performs the first-year phone screen, so expect tough technical questions. On your onsite interview, youll interview with four to six people, one of whom will be a lunch interviewer. Interviewer feedback is kept confidential from the other interviewers, so you can be assured that you enter each interview with b lank slate.Your lunch interviewer doesnt submit feedback, so this is a great opportunity to ask honest questions. Written feedback is submitted to a hiring committee of engineers to mother a hire/no-hire cheeration. Feedback is typically broken down into four categories (Analytical Ability, Coding, Experience and Communication) and you are given up a score from 1. 0 to 4. 0 overall. The hiring committee under bides that you cant be expected to excel in all(prenominal) interview, but if treble people raise the same red flag (arrogance, poor coding skills, and so forth, that can disqualify you.A hiring committee typically wants to see one interviewer who is an enthusiastic endorser. In other words, a packet with scores of 3. 6, 3. 1, 3. 1 and 2. 6 is better than all 3. 1s. Your phone screen is usually not a promoter in the final decision. The Google hiring process can be slow. If you dont hear back within one week, politely ask your recruiter for an update. A lose of response alleges nothing about your performance. Definitely Prepare As a web-based company, Google cares about how to blueprint scalable system. So, collide with sure you prepare question from Large Scale. Additionally, many a(prenominal) Google interviewers will ask questions involving snap shifting and Bit Manipulation, so please brush up on these questions. Whats incompatible Your interviewers do not make the hiring decision. Rather, they enter feedback which is passed to a hiring committee. The hiring committee recommends a decision which can bethough rarely isrejected by Google executives. emailprotected google. com 2009 CAREERCUP 9 The Yahoo Interview Resume Selection & Screening era Yahoo tends to only recruit at the expire 10 20 schools, other candidates can still get interviewed by means ofYahoos job board (or better yet if they can get an internal referral). If youre one of the lucky ones selected, your interview process will start off with a phone screen. Your phone s creen will be with a higher-ranking employee (tech lead, manager, etc). Onsite Interview You will typically interview with 6 7 people on the same team for 45 minutes each. Each interviewer will carry an area of focus. For example, one interviewer might focus on infobases, while another interviewer might focus on your understanding of computer architecture.Interviews will often times be composed as follows 5 minutes customary conversation. Tell me about yourself, your projects, etc. 20 minutes Coding question. For example, hold merge sort. 20 minutes System design. For example, design a large distributed cache. These questions will often focus on an area from your past experience or on something your interviewer is curDefinitely Prepare rently working on. Decision At the end of the day, you will likely meet with a Program Manager or someone else for a general conversation ( crop demos, concerns about the company, your competing offers, etc).Meanwhile, your interviewers will d iscuss your performance and attempt to come to a decision. The hiring manager has the ultimate say and will weigh the positive feedback against the negative. If you pick up done well, you will often get a decision that day, but this is not always the case. in that location can be many earths that you might not be told for some(prenominal) days for example, the team may feel it demands to interview several(prenominal) other people. Yahoo, virtual(prenominal)ly as a rule, asks questions about system design, so make sure you prepare that. They want to eff that you can not only write code, but that you can design software.Dont fretting if you dont have a background in this you can still reason your way through it Whats Unique Your phone interview will likely be performed by someone with more influence, such(prenominal) as a hiring manager. Yahoo is withal unusual in that it often gives a decision (if youre hired) on the same day. Your interviewers will discuss your performan ce while you meet with a final interviewer. 10 2009 CAREERCUP exclusively for emailprotected google. com Interview War Stories The View from the Other Side of the Front, by Peter BaileyFor the eager candidate acquire ready for a self-aggrandizing job interview, Cracking the Technical Interview is an invaluable reference, containing excellent coaching job and practice material that gives you an inside edge on the interview process. However, as you go over your old information structures textbook and drill yourself with homespun discrete math flash cards, dont make the slue of thinking of the interview as a kind of high-pressure support show that if you and give all the right answers to the tech questions, you excessively can win a shiny new career (this week, on Who Wants to be a Software Engineer? While the technical questions on computer science obviously are very primal, the more or less important interview question is not covered in this guidebook. In fact, its often the single most important question in your interviewers minds as they grill you in that little room. Despite the questions on polymorphism and haemorrhoid and virtual machines, the question they really want an answer to is Would I have a beer with this guy? Dont look at me like that, Im serious Well, I may be embellishing a little, but hear me out.The menstruation Im turn uping to make is that interviewers, especially those that you might work with, are probably just as anxious as you are. Nonsense, you say, as a nervous young professional, correcting your gasp for lint while you acte your fingernails, time lag for the interview team to show up in the front lobby. After all, this is the big leagues, and these guys are just wait for you to slip up so they can rip you apart, laugh at your shriveled corpse, and grind your career dreams to dust beneath the heels of their boots. dear? Just like pledge week, back in freshman year?Right? Hmmm? Nothing could be further from the t ruth. The team of developers and managers interviewing you have their own tasks and projects waiting for them, back at their own desks. Believe me, theyre hoping that every interview is qualifying to be the last one. Theyd rather be doing anything else. on that point might be a batch of upcoming projects looming on their calendar, and they engage more manpower if theyre going to up to now have a prayer of making their deadline. But the last guy the agency sent over was a complete flake who railed about Microsofts lousiness for fractional an hour.And the one sooner that couldnt code his way out of a wet paper bag without using copy-and-paste. Sheesh, they think, where is HR getting these guys? How hard can it be to hire one lousy somebody? While they may not literally be asking themselves Would I have a beer with this guy (or gal), they are looking to see how well you would fit in with the team, and how you would affect team chemistry. If they hire you, youre all going to be spending a lot of time in concert for 11 2009 CAREERCUP exclusively for emailprotected google. com Interview War Stories he next hardly a(prenominal) months or years, and they want to fare that they can rely on you and perchance nonetheless come to consider you a friend and colleague. They want to distinguish that they can depend on you. And as tempting as it might be to them to just settle and hire the next person who comes along, they realise better. In many companies, particularly large U. S. companies, its harder to fire soulfulness than it is to hire somebody. (Welcome to the US Land of Lawsuits ) If they hire a dud, theyre stuck with them. That person might be unproductive or, even worse, a drain on the teams productivity.So they keep interviewing, until they begin the right person. They receipt that its better to reject a good candidate than hire a mentally ill one. Some of those interviews are real doozies. once youve interviewed long complete, you take a shit up a repertoire of horror stories. War stories, of candidates who looked promising on paper until the interviews went terribly, terribly price. These war stories are not only slapstick theyre similarly instructive. Names have been changed to protect the innocent or downright ridiculous. zyxwvutsrqponmlkjihgfedcba ZYXWVUTSRQPONMLKJIHGFEDCBA emailprotected google. comkjlslen 0987654321+_=-)(*&%$ ,. /? ABCDEZYXW abcdeyxw asdsasdFGJwRXGs75rpqR3oFWHMJHp-RQ. LLqJ. H-rsdkktNNsasdf emailprotected google. com emailprotected google. com 2009 CAREERCUP 12 Interview War Stories Pop Divas motivating Not Apply Leonard was a very promising C++ coder, triplet years out of college, with a substantialness work history and an revealing skill set. He proved on the phone screen that he was above-average technically, and so he was invited in for an interview. We needed a savvy C++ person to work on a piece of middleware that interfaced with our infobase, and Leonard seemed like a sure fit.How ever, once we started lecture to him, things went south in a hurry. He spent most of the interview criticizing every tool and platform that we questioned him on. We utilise SQL Server as our database? Puhleease. We were planning to switch to Oracle soon, right? Whats that? Our team used Tool A to do all our coding in? Unaccep instrument panel. He used Tool B, and only Tool B, and afterwards he was hired, wed all have to switch to Tool B. And wed have to switch to Java, because he really wanted to work with Java, patronage the fact that 75 percent of the codebase would have to be rewritten.Wed convey him later. And oh, by the way, he wouldnt be making any meetings before ten oclock. Needless to say, we encouraged Leonard to seek opportunities elsewhere. It wasnt that his ideas were bad in fact, he was technically right about many things, and his (strong) opinions were all backed with solid fact and sound reason (except for the ten oclock thing we think he may have just been mak ing a power play. ) But it was obvious that, if hired, Leonard wasnt going to play well with others he would have been toxic kryptonite for team chemistry.He truly managed to offend two of the team members during the forty-five minutes of his interview. Leonard as well as made the mistake of assuming that Code Purity and Algorithm hit were always more important than a clientele deadline. In the real world, there are always compromises to be made, and make outing how to work with the business analysts is just as important as knowing how to refactor a emollient out of code. If Leonard would not have gotten along with other IT people, he definitely wouldnt have gotten along with the business folks. Maybe you can get away(p) ith hiring a Leonard if hes one of the best ten coders in the world (he wasnt). But he was the variantic failure example for the Would you have a beer with this guy? test. 13 2009 CAREERCUP exclusively for emailprotected google. com Interview War Stories What We begin Here is Failure to Communicate Trisha was a mid-level Java developer with a solid history of middleware and JSP work on her resume. Since she was local, we invited her in for an interview without a phone screen. When we started asking her questions, it quickly became obvious that Trisha was a woman of few words.Her answers were short and often composed of yes/no responses, even to questions that were meant to start a dialog. Once she did start opening up, I still wasnt sure she was actually talking. I saw her lips moving, and heard mumbling sounds coming out, but it wasnt anything that sounded like English. Im not sure if Trisha was nervous or just shy, but either way, I had to ask her numerous quantify to repeat herself. Now I was the one getting nervous I didnt want to be the guy who ruined the interview, so I pulled back on my questions. The other folks in the room and I exchanged uneasy glances.We felt like we were on a Seinfeld episode. It was almost impossible to understand Trisha, and when she did speak up, her halting, un veritable, confused speech patterns made us feel more like code breakers than interviewers. I am not exaggerating to say that I did not understand a single answer she gave during the interview. Knowing, alone, isnt good enough. Youre going to be talking with other technical people, and youre going to be talking to customers, and sales reps, and Betty from Marketing. You will write something eventually, whether its documentation, or a project plan, or a requirements document.The word processor might correct your spelling, but it wont correct your lousy make-up. The ability to communicate thoughts and ideas, in a clear, concise manner, is an absolutely invaluable skill that employers seek. The same goes for verbal communication. I used to work with a co-worker who double overd the length of every meeting he was in, because he could not answer a question in less than ten minutes. Hey, Dennis, what time is it? Well, t hats kind of interesting, because I just happened to be reading an article on cesium quantify and leap back ups and the history of the Gregorian Calendar and Ill spare you the rest. emailprotected google. com 2009 CAREERCUP 14 Interview War Stories You backside Count on Me, Just Not Until Early Afternoon Ahhh, 1999. The crest of the dot-com bubble, and the tightest labor market in history. Our company was racing to expand its development team, and we would have hired a German Shepherd if it knew HTML. Instead, we wound up hiring Ian. We shouldve hired the dog. Ian was a cheerful, friendly guy who had a gift of natural charisma. He got along fantastically with all of the interviewers, and seemed very intelligent.Skillwise, he was adequate. He hadnt written a single line of computer code outside of his college telephone circuits, and didnt even have his own e-mail address. When we gave Ian the chance to ask us questions at the end of the interview, he asked about flexible work h ours, and how soon he could take vacation time. Instead of showing an interest in the career opportunities, or in companys growth prospects, he asked whether he could take the all-you-could-drink break room soda home with him. The questions grew more flaky from there. Ian was very interested in our Legal Assistance benefit.He wanted to know if it covered the cost of filing lawsuits, if it covered him if he got sued himself, if it applied to any lawsuits he currently was involved in, and if he could theoretically use it to sue the company itself. He also asked us if he could use it to help him fix some unpaid speeding tickets. In any other year, that should have been it for Ian right there. But, in 1999, we were hiring anybody who was even remotely competent. Ian collected pay jeers from us for eighteen months, and he was about as productive as a traffic cone.He usually sauntered into the office around ten-thirty with some sort of foursquare excuse (by my count, he had to wait for the cable guy sixteen quantify in a six-month period). He usually killed the morning by say e-mail and playing ping-pong, before breaking for a two-hour lunch. After lunch, it was more pingpong, and maybe an hour of writing bad code, before bolting the office one-time(prenominal) around trey. He was the dictionary definition of unreliable. Remember, your potential future team members need to know that they can rely on you. And they need to know that you wont need constant supervision and hand-holding.They need to know that youre able to figure things out on your own. One of the most important messages that you, as a candidate, can convey in your interview is hiring me will make your zippys easier. In fact, this is a large part of the reason for the famously difficult interview questions at places like Amazon and Google if you can enshroud that kind of unpredic prorogue pressure in an interview, then you stand a good chance of being useful to them on real projects. To cite a mo re subtle example, once I was on a four person team that was desperately trying to recruit new members to help work on an old pile of software.It was a real mess wed inherited a nasty orb of spaghetti, and we needed people who could jump in, figure things out, and be part of the solution. in that location was one very refreshed fellow, Terry, who would have been a great plus for our team 15 2009 CAREERCUP exclusively for emailprotected google. com Interview War Stories but we didnt hire him, despite his excellent technical and personal skills. It was because he insisted on meticulous written instructions for every tone of voice of the coding process.He wasnt going to make a suggestion or take any initiative or blow his nose, for that matter without a mile-long audit chase after and a dozen signatures. While he insisted that he worked that way for reasons of smell (a defensible point), we got the impression that it had more to do with butt-covering, and we simply didnt hav e the time for that kind of bureaucracy. Terry would have been an excellent fit in a government or aerospace IT surgical incision, something that required ISO 9000 procedures. But he would have never fit into our team he would have been a burden, not an asset.emailprotected google. com 2009 CAREERCUP 16 Interview War Stories My Spider Senses are Tingling I can think of lots of interviews that just fell into the general social flesh of weird and un satisfactory The Java coder who apparently considered hygiene optional, and had the interview room smelling like week-old blue cheese within ten minutes (my piths were weting). The young fresh-out-of-college graduate with a tongue lancinate that kept tick-tick-ticking against his teeth as he talked (after half an hour, it was like Chinese piddle torture).The girl who wore an iPod through her interview, with the volume turned loud enough that she actually had to ask the interviewers to repeat themselves a few times. The poor, h yper-nervous fellow who was egest like a marathon runner for half an hour. The girl who wore a T-shirt with an obscene political slogan to her interview. The guy who asked (seriously) at the end of his interview, So, are there any hot chicks in our department? Those are the interviews where we politely thank the people for their time, shake their hand (except for the sweaty guy), then turn to each other after the door closes and ask did that really just happen?Nobody is saying that you have to be a bland, windy zombie in a Brooks Brothers suit and tie. Remember, the interview team wants you to be the one, but theyre also very sick about the possibility that youre going to be more of a distraction than an asset. Dont talk or behave in a way that will set off their early ideal radar. Whether or not somebody bothers to behave professionally during an interview is often a very good indicator of what kind of teammate theyre going to be. Rudimentary social skills are part of the a nswer to Would I have a beer with this guy? , or at least, Will I mind working next to this guy for six months? From the interviewers point of view, theyre picking a neighbor that theyre going to live and work with 200 hours per week for foreseeable future. Would you really want a neighbor that smelled like a hog rendering plant? 17 2009 CAREERCUP exclusively for emailprotected google. com Interview Questions Study hard, practice and good luck How this volume is Organized The interview questions in this book are grouped into categories, with a page preceding each category offering advice and other information.Within each category, the questions are sorted by approximate level of difficulty. Solutions for all questions are at the back. How to Use this Book An effective interview is not about memorizing interview questions, but rather, about applying an understanding of concepts and demonstrating your problem solving ability. Use these questions to play the gaps in your knowledge and to learn problem solving techniques that you can apply to new questions. Advice for Devs Your interview will be most likely not be conducted on a computer. Thus, when you practice the problems in this book, we recommend writing them down on paper first.Then, type your solution into the computer on the dot as you wrote it and see how you did. Special Advice for SDETs Not only do SDETs have to be great testers, but they also have to be great coders. Thus, we recommend that you complete the coding problems in this book with an eye for testing them. Even when the question doesnt specifically ask it, you should ask yourself, how would I test this? Remember any problem can be an SDET problem. Suggestions and determineions While we do our best to pick up that all the solutions are correct, mistakes will be made. Moreover, sometimes there is no right answer.If youd like to offer a suggestion or correction, please submit it at http// xrl. us/ccbook emailprotected google. com 2009 CA REERCUP 18 Applied Mathematics How to onrush CHAPTER-1 many an(prenominal) of the so-called Applied Mathematics problems read as brain teasers at first, but can be worked through in a discursive way. Just remember to rely on the rules of mathematics to develop an approach, and then to conservatively translate that idea into code. interpreter given up two verse m and n, write a method acting to return the first repress r that is divisible by both (e. g. , the least common multiple).The approach shot What does it mean for r to be divisible by m and n? It means that all the primes in m mustiness go into r, and all primes in n must be in r. What if m and n have primes in common? For example, if m is divisible by 35 and n is divisible by 37, what does this mean about r? It means r must be divisible by 37. The Rule For each prime p such that pa m (e. g. , m is divisible by pa) and pb n, r must be divisible by pmax(a, b) The Algorithm Define q to be 1. for each prime offspring p less than m and n find the largest a and b such that pa m and pb n let q = q * pmax(a, b) return qThings to Watch Out For 1. 2. Be careful with the release in precision between floats vs. multiply. Dont support that a cherish (such as the slope of a line) is an int unless youve been told so. Prime Numbers 1. 2. both bite can be written as a product of primes. Example 504 = 23 * 32 * 7 f x is divisible by y, then every prime factor in y must be ready in x. Example If 504 is divisible by y, then y could be 168 (23 * 3 * 7), or 21 (3 * 7), or 4 (22), or many other things. Y could not, however, be equal to 10 (5 * 2), since 5 is not bring in x 19 2009 CAREERCUP exclusively for emailprotected oogle. com Applied Mathematics CHAPTER-1 1. 1 relieve a method to generate the nth Fibonacci number _______________________________________________________________________pg 69 1. 2 bring out a method to count the number of 2s between 0 and n. ensample infix 35 product 14 list of 2s 2, 12, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32 _______________________________________________________________________pg 70 1. 3 Given two lines on a Cartesian plane, determine whether the two lines would intersect. _______________________________________________________________________pg 74 1. Given two squares on a two dimensional plane, find a line that would cut these two squares in half. _______________________________________________________________________pg 75 1. 5 make unnecessary an algorithm which computes the number of trailing zeros in n factorial. voice input 11 output 2 (11 = 39916800) _______________________________________________________________________pg 76 1. 6 Write a function that adds two numbers. You should not use + or any arithmetical hookers. _______________________________________________________________________pg 77 1. Write a method to implement *, , / operations. You should use only the + operator. ___________________________________________ ____________________________pg 79 1. 8 Design an algorithm to find the kth number such that the only prime factors are 3, 5, and 7. _______________________________________________________________________pg 81 1. 9 A funfair is designing a tower routine consisting of people standing atop one anothers shoulders. For practical and aesthetic reasons, each person must be both shorter and lighter than the person below him or her.Given the heights and weights of each person in the circus, write a method to compute the largest possible number of people in such a tower. EXAMPLE Input(ht, wt) (65, 100) (70, 150) (56, 90) (75, 190) (60, 95) (68, 110) take The longest tower is length 6 and includes from top to bottom (56,90) (60,95) (65,100) (68,110) (70,150) (75,190) _______________________________________________________________________pg 84 1. 10 Given a two dimensional graph with 6000 points on it, find a line which passes the most number of points. ______________________________________ ________________________________pg 86 2009 CAREERCUP 20 Arrays & Hash Tables How to begin CHAPTER-2 While not all problem can be solved with a chop up table, a shocking number of interview problems can be. Keeping track of which items youve already seen? Hash table. Needing a way to efficiently look up data? Hash table. The list goes on and on. You should become very extremely comfortable with hash tables how to implement them and how to use them. Hash Tables A hash table is a data structure that associates keys with jimmys for O(1) lookup.Hash tables are frequently, though not always, implemented with an coordinate. A simple implementation of a hash table that hashes a string to a Person is as follows class HashTable Person data = new PersonMAX_HASH_KEY int getId(string s) /* return a key for this string */ bool contains(string key) int id = getId(key) if (data247) return reliable return false void insert(string s, Person p) datagetId(s) Note This implementation does n ot handle collision. Collisions can be handled by chaining (eg, using a associate list), or a variety of other ways. Vector (Dynamically Resizing Array)A vector, or a dynamically resizing array, is an array that resizes itself as needed while still providing O(1) gravel. A typical implementation is that when a vector is full, the array doubles in size. Each doubling takes a long time (O(n)), but happens so rarely that its asymptotic time is still O(1). 21 2009 CAREERCUP exclusively for emailprotected google. com Arrays CHAPTER-2 2. 1 make we have an array a1, a2, , an, b1, b2, , bn. Implement an algorithm to change this array to a1, b1, a2, b2, , an, bn. _______________________________________________________________________pg 87 . 2 Design an algorithm and write code to remove the duplicate characters in a string without using any additional buffer. set One or two additional variables is fine. An exceptional copy of the array is not. FOLLOW UP Write the test cases for thi s method. _______________________________________________________________________pg 88 2. 3 You are given an array of integers (both positive and negative). Find the free burning sequence with the largest sum. Return the sum. EXAMPLE input 2, -8, 3, -2, 4, -10 output 5 eg, 3, -2, 4 _______________________________________________________________________pg 90 2. Design an algorithm to find all pairs of integers within an array which sum to a specified value. _______________________________________________________________________pg 91 2. 5 An array A1 n contains all the integers from 0 to n except for one number which is missing. In this problem, we cannot access an entire integer in A with a single operation. The elements of A are stand fored in binary, and the only operation we can use to access them is fetch the jth bit of Ai, which takes constant time. Write code to find the missing integer. Can you do it in O(n) time? ___________________________________________________________ ___________pg 93 2009 CAREERCUP 22 Bit Manipulation How to Approach CHAPTER-3 Bit manipulation can be a scary thing to many candidate, but it doesnt need to be If youre shaky on bit manipulation, we recommend doing a couple arithmetic-like problems to boost your skills. Compute the hobby by hand 1010 0001 1010 1 1010 + 0110 10011001 0xFF 1 11001010 1001 & 1100 0xAB + 0x11 If youre still uncomfortable, examine very careful what happens when you do subtraction, addition, etc in base 10. Can you repeat that work in base 2? Things to Watch Out For Its really easy to make mistakes on these problem so, be careful When youre writing code, chip off and thinking about what youre writing every couple lines. When youre done, check through your entire code. If youre bit shifting, what happens when the digits get shifted off the end? Make sure to think about this case to ensure that youre handling it correctly. 1 & 0 = 0 1 0 = 1 1 0 = 1 0 & 1 = 0 0 1 = 1 0 1 = 1 1 & 1 = 1 1 1 = 1 1 1 = 0 And (&) 0 & 0 = 0 Or () 0 0 = 0 Xor () 0 0 = 0 Left Shift x 2 = 00000110 00011001 4 = 00000001 exclusively for emailprotected oogle. com 23 2009 CAREERCUP Bit Manipulation CHAPTER-3 3. 1 Write a function int BitSwapReqd(int A, int B) to determine the number of bits required to switch integer A to integer B. EXAMPLE _______________________________________________________________________pg 94 3. 2 If you were to write a program to swap odd and even bits in integer, what is the negligible number of instructions required? (eg, bit 0 and bit 1 are swapped, bit 2 and bit 3 are swapped, etc). EXAMPLE _______________________________________________________________________pg 95 3. 3 Write a method which finds the maximum of two numbers.You should not use if-else or any other comparison operator. EXAMPLE _______________________________________________________________________pg 96 3. 4 Given a (decimal e. g. 3. 72) number that is passed in as a string, chump the binary representa tion. If the number can not be represented accurately in binary, strike ERROR _______________________________________________________________________pg 97 3. 5 You are given two 32-bit numbers, N and M, and a two bit positions, i and j. Write a method to set all bits between i and j in N equal to M (eg, M becomes a substring of N located at i and starting j).EXAMPLE _______________________________________________________________________pg 99 3. 6 Write a function to swap a number in place without temporary variables. ______________________________________________________________________pg 100 3. 7 Given an integer, print the next smoothest and next largest number that have the same number of 1 bits in their binary representation. ______________________________________________________________________pg 101 input N = 10000000000, M = 10101, i = 2, j = 6 output N = 10001010100 Input 5, 10 Output 10 Input 10001010 Output 01000101 Input 31, 14 Output 2 2009 CAREERCUP 24 Brain Teasers D o companies really ask brain teasers? CHAPTER-4 While many companies, including Google and Microsoft, have policies banning brain teasers, interviews still sometimes ask these tricky questions. Advice on Approaching Brain Teasers Dont fright when you get a brain teaser. Interviewers want to see how you tackle a problem they dont expect you to immediately know the answer. belong talking, and show the interviewer how you approach a problem. In many cases, you will also find that the brain teasers have some connection back to perfect laws or theories of computer science.If youre stuck, we recommend simplifying the problem. Solve it for a small number of items or a special case, and then see if you can understand it. Example You are trying to cook an egg for on the button 15 minutes, but instead of a timer, you are given two catchs which burn for exactly 1 hour each. The lots, however, are of uneven densities eg, half the rope length-wise might take only 2 minutes to burn. The a pproach 1. 2. 3. 4. 5. 6. 7. What is important? Numbers usually have a meaning understructure them. The fifteen minutes and two ropes were picked for a reason. SimplifyYou can intimately time one hour (burn just one rope). Now, can you time 30 minutes? Thats half the time it takes to burn one rope. Can you burn the rope twice as fast? Yes (Light the rope at both ends. ) Youve now learned (1) You can time 30 minutes. (2) You can burn a rope that takes X minutes in just X/2 minutes by lighting both ends. Work backwards if you had a rope of burn-length 30 minutes, that would let you time 15 minutes. Can you remove 30 minutes of burn-time from a rope? You can remove 30 min of burn-time from Rope 2 by lighting Rope 1 at both ends and Rope 2 at one end.Now that you have Rope 2 at burn-length 30 min, start cooking the egg and light rope 2 at the other end. When Rope 2 burns up, your egg is done 25 2009 CAREERCUP exclusively for emailprotected google. com Brain Teasers CHAPTER-4 4. 1 Add arithmetic operators (plus, minus, times, divide) to make the interest expression true 3 1 3 6 = 8. You can use any parentheses youd like. ______________________________________________________________________pg 103 4. 2 You have a 5 quart jug and 3 quart jug, and an unlimited supply of water (but no measuring cups). How would you come up with exactly four quarts of water?NOTE The jugs are oddly shaped, such that filling up exactly half of the jug would be impossible. ______________________________________________________________________pg 104 4. 3 There is a edifice of 100 floors. If an egg drops from the Nth floor or above it will break. If its dropped from any floor below, it will not break. Youre given 2 eggs. Find N, while minimizing the number of drops for the worse case. ______________________________________________________________________pg 105 4. 4 A bunch of men are on an island. A genie comes down and gathers everyone together and places a magical hat on some peoples heads (e. . , at least one). The hat is magical it can be seen by other people, but not by the wearer of the hat himself. To remove the hat, you must dunk yourself underwater at exactly midnight. If there are n people and c hats, how long does it take the men remove the crowns? The men cannot tell each other (in any way) that they have a hat. FOLLOW UP promote that your solution is correct. ______________________________________________________________________pg 106 4. 5 There are 100 shut lockers in a hallway. A man begins by opening all the 100 lockers. Next, he closes every second locker.Then he goes to every third locker and closes it if it is open or opens it if it is closed (eg, he toggles every third locker). After his 100th pass in the hallway, in which he toggles only locker number 100, how many lockers are open? ______________________________________________________________________pg 108 2009 CAREERCUP 26 C / C++ How To Approach CHAPTER-5 A good interviewer wont demand that you code in a talking to you dont profess to know. Hopefully, if youre asked to code in C++, its listed on your resume. If you dont remember all the APIs, dont worryyour interviewer probably doesnt eitherWe do recommend, however, canvass up on basic C++ syntax. Pointer Syntax int p = v = Foo int *p // Defines arrow. &q // Sets p to address of q. *p // Set v to value of q. *f = new Foo() // Initializes f. k = f-x // Sets k equal to the value of fs member variable. C++ Class Syntax class MyClass private double var public MyClass(double v) var = v MyClass() double Update(double v) double ComplexUpdate(double v) var = v return v C++ vs Java A very common answer in an interview is describe the differences between C++ and Java. If you arent comfortable with any of these concepts, we recommend reading up on them. 1. 2. 3. 4. 5. 6. Java runs in a virtual machine. C++ natively supports unsigned arithmetic. In Java, parameters are always passed by value (or with objects, their r eferences are passed by value). In C++, parameters can be passed by value, pointer, or by reference. Java has built-in garbage collection. C++ allows operator overloading. C++ allows multiple inheritance of classes. Thought Which of these might be considered strengths or weaknesses of C++ or Java? wherefore? In what cases might you involve one language over the other? 7 2009 CAREERCUP exclusively for emailprotected google. com C / C++ CHAPTER-5 5. 1 What is the difference between a struct and a class? Where would you use each? ______________________________________________________________________pg 109 5. 2 Write a method to print the last ten lines of an input file using C. ______________________________________________________________________pg 110 5. 3 Compare and contrast a hash table vs. an STL map. How is a hash table implemented? If the number of inputs are small, what data structure options can be used instead of a hash table? _____________________________________________ ________________________pg 111 5. 4 How do a virtual functions work in C++? ______________________________________________________________________pg 112 5. 5 What is the difference between deep copy and shallow copy? exempt how you would use each. ______________________________________________________________________pg 113 5. 6 In a class, the new operator is used for allocating memory for new objects. Can this be done using malloc? If yes, how? If no, why not? Are there any restrictions associated with the use of malloc in place of new? _____________________________________________________________________pg 114 5. 7 What is the significance of the keyword volatile in C? ______________________________________________________________________pg cxv 5. 8 What is name hiding in C++? ______________________________________________________________________pg 116 5. 9 Why does a destructor in base class need to be stated virtual? _____________________________________________________________ _________pg 117 5. 10 Write a method that takes a pointer to a pommel structure as a parameter and returns a complete copy of the passed-in data structure.The Node structure contains two pointers to other Node structures. For example, the method signature could look like so Node* Copy(Node* root) Note Do not make any assumptions about the data structure it could be a tree, linked list, graph etc. timber free to choose the language you are most comfortable with (C or C++ are preferred) In addition to the function code, write a complete suite of unit tests for this problem. ______________________________________________________________________pg 119 5. 11 Write a smart pointer (smart_ptr) class. _____________________________________________________________________pg 120 2009 CAREERCUP 28 Counting and Combinatorics How to Approach CHAPTER-6 While some problems in this chapter are simply coding problems, understanding the mathematical solution will help you sanity check your solutio n. For example, if you know how many subsets there are of a set, you can check to make sure that your algorithm to print all subsets will give you the correct number of subsets. When computation the number of ways of doing something, think about doing it step by step. The following two examples will illustrate this technique.How many ways can you pick k elements from n elements, if order matters and elements are not replaced? Eg if we pick 5 different letters, abcde is considered to be different from edcba. The Approach We have n choices for the first draw. For the second draw, we only have n-1 since one is removed. Then n-2, . When we draw k times, we get down to n-k+1 choices on the last draw. So, n * (n-1) * (n-2)* * (n-k+1) The Solution n / (n-k) How many ways can you pick k elements from n elements, if order does not matter and elements are not replaced? Were now just throwing letters into a bucket. Picking a, b is the same thing as b, a.The Approach If you compare this proble m to the earlier one, weve basically double (or triple, quadruple, etc) counted items. That is, abc, acb, bac, bca, cab, cba were all considered unique in the previous solution but now theyre considered the same. Just how many times has abc been included (in its other forms)? 3 times, since there are 3 ways of rearranging abc. In fact, every item has been included 3 times, when it should have been included just once So, we divide our previous answer by 3 (or, more generally, k ). We now get n / (k * (n-k) ). This solution is often written as n-choose-k or nCk. 9 2009 CAREERCUP exclusively for emailprotected google. com Counting and Combinatorics CHAPTER-6 6. 1 In how many different ways can a cube be painted by using three different colors of paint? ______________________________________________________________________pg 121 6. 2 Imagine a robot sitting on the upper left hand corner of an NxN grid. The robot can only move in two directions right and down. How many possible paths are there for the robot? FOLLOW-UP Imagine sure squares are off limits, such that the robot can not step on them. Design an algorithm to print all possible paths for the robot. _____________________________________________________________________pg 122 6. 3 Write a method to compute all permutations of a string. ______________________________________________________________________pg 123 6. 4 Implement an algorithm to print all valid (eg, properly undetermined and closed) combinations of n-pairs of parentheses. EXAMPLE input 3 (eg, 3 pairs of parentheses) output ()()(), ()(()), (())(), ((())) ______________________________________________________________________pg 124 6. 5 Write a method that returns all subsets of a set. ______________________________________________________________________pg 125 2009 CAREERCUP 30 Database How to Approach CHAPTER-7 You could be asked about databases in a variety of ways write a SQL query, design a database to hold certain data, or to design a lar ge database. Well go through the latter two types here. broken Database Design Imagine you are asked to design a system to represent a schools registrar course information, departments, course enrollment, teachers, etc. What are the key objects? Student. Professor. Course. Department. How do they relate to each other? *NOTE Im going to make some assumptions here for the purposes of writing up this explanation.In your interview, dont make assumptions select your interviewer instead. Many-to-Many A course can belong to multiple departments, and each department can have multiple courses. So, create a separate table DepartmentCourse that acts as a pairing of the two. DepartmentCourse has just a department_id field and a course_id field. A disciple can be in multiple courses, a course can have multiple students. So, do the same as above and create a StudentCourse table. A course only has one professor. A professor can teach multiple courses. So, add a field professor_id to the Cours es table. One-to-Many Large Database Design When designing a large, scalable database, joins (which are required in the above examples), are generally very slow. Thus, you must denormalize your data. Think carefully about what when data will be usedyoull probably need to duplicate it in multiple tables. 31 2009 CAREERCUP exclusively for emailprotected google. com Database CHAPTER-7 7. 1 Write a method to find the number of employees in each department when we have the following tables ______________________________________________________________________pg 126 7. 2 What are the different types of joins?Please rationalize how they differ and why certain types are better in certain situations. ______________________________________________________________________pg 127 7. 3 What is normalization? Explain the pros and cons. ______________________________________________________________________pg 128 7. 4 Draw a entity-relationship diagram for a database with companies, people, and professionals (people who work for companies). ______________________________________________________________________pg 129 7. 5 You have to design a database that can store terabytes of data. It should support efficient range queries. How would you do it? _____________________________________________________________________pg 130 Employees containing Emp_ID, Emp_Name and Dept_ID (Primary key) Departments containing Dept_Name and Dept_ID (foreign key) 2009 CAREERCUP 32 Debugging Existing Code How to Approach CHAPTER-8 Sometimes, in an interview, an interviewer asks you to look at a piece of code and identify the mistakes. We recommend the following approach 1. 2. 3. go steady the code and understand what its expected to do. Ask your interviewer what types of data its expected to handle, where itll be used, etc. fashion for syntax errors does everything type check? s the class declaration correct? Look for hot floater 4. 5. If you see float and doubles, check for precision errors If you see division, check for round errors If you see memory allocation, check for memory leaks If you see unsigned ints, check to see if the int might ever be negative If you see bit manipulation, check for correctness The normal case The boundary cases (null, 0, 1, MAX, etc) Run through the code with a few examples Does it do everything its expect to? For example, if the code is supposed to return everyone in a database under 21, does it only look for students?Maybe it should be looking for teach-ers as well? Does it handle upset(prenominal) cases? What if it takes in a list and it has a loop? 6. Further Advice 1. 2. Look at the space and time complexitycan you improve it? Correct the mistakes in the code. But do so carefully Dont simply make changes until it works. Deeply understand the issues and then correct them. 33 2009 CAREERCUP exclusively for emailprotected google. com Debugging Existing Code 8. 1 Explain what the following code does ((n & (n-1)) == 0) CHAPTER- 8 ______________________________________________________________________pg 131 8. Find the mistake(s) in the following code unsigned int i for (i = 100 i Other int foo() printf(here we are ) main() typedef Foo typedef Derived Derived_inst Derived_inst ii ii. foo() ______________________________________________________________________pg 133 2009 CAREERCUP 34 Games How To Approach CHAPTER-9 Sometimes interviewers ask these problems simply because theyre fun, but often, its also because game problems are heavy on object oriented design. dramatic play problems tend to be more free form and thus they give you the chance to demonstrate how you really code.Define Data Structures When implementing something so free form, ask yourself, Where can I define a class or a struct? When in doubt, define a new class or struct. It tells the interviewer that you care about the maintainability of your code. Validate Your Assumptions Be careful about making assumptions. Suppose youre asked to i mplement the word game Scrabble. Dont assume that the dictionary will be in Englishor even in that character set. It could be in any language Ask your interviewer lots and lots of questions so that you know what to implement. Are you solving this problem once, or many times?Sometimes the solution will change depending on whether or not your code will be called multiple times. For example, suppose youre asked to find all anagrams of a word. If youre calling this code just once, it may be fastest just to rearrange the letters and check if theyre in the dictionary. But, if youre going to call the code multiple times, its now fastest to precompute data by iterating through all the words in the dictionary. Can you generalize your code, or part of it? If you really want to go above and beyond, try writing your code as though it were a more generalize case.For example, if youre trying to figure out if a tic-tac-toe board has a winner, you might suggest to your interviewer solving it for t he more general NxN case. If you go down this path though, be warnedsometimes problems are trickier than they appear. Also, make sure you discuss this with your interviewer so he/she knows what youre doing. 35 2009 CAREERCUP exclusively for emailprotected google. com Games CHAPTER-9 9. 1 Design an algorithm to figure out if someone has won in a game of tic-tac-toe. ______________________________________________________________________pg 135 9. The Game of Master Mind is compete as follows The computer has four slots containing balls that are red (R), yellow (Y), light-green (G) or blue (B). For example, the computer might have RGGB (eg, Slot 1 is red, Slots 2 and 3 are green, 4 is blue). You, the user, are trying to see the solution. You might, for example, guess YRGB. When you guess right color for the right slot, you get a hit. If you guess a color that exists but is in the wrong slot, you get a psuedo-hit. For example, the guess YRGB has 2 hits and one pseudo-hit. For each guess, you are told the number of hits and pseudo hits.Write a method that, given a guess and a solution, returns the number of hits and pseudo hits. ______________________________________________________________________pg 137 9. 3 There is an 88 slicker board in which two diagonally opposite corners have been cut off. You are given 31 dominos in which a single domino can cover exactly two squares. Can you use the 31 dominos to cover the entire board? Prove your answer (by providing an example, or showing why its impossible). ______________________________________________________________________pg 138 9. Find a way to arrange 8 queens on a chess board so that none of them share the same row, column or diagonal. ______________________________________________________________________pg 139 9. 5 Othello is played as follows Each Othello piece is white on one side and black on the other. On your turn, you place a piece on the board so that your color is facing up. You must pick a spot such that your opponents pieces are either on the left and the right, or on the top and the bottom. All of your opponents pieces on the line between two of yours are then turned over, to become yours. Your goal is to own the most pieces.Design the game Othello. Write a method to check whether someone has won the game. ______________________________________________________________________pg 141 2009 CAREERCUP 36 Java How to Approach CHAPTER-10 While Java related questions are found throughout this book, this chapter deals with questions about the language and syntax. You generally will not find many questions like this at the larger software companies (Microsoft, Google, Amazon, etc), which tend to countermand trivia based questions, but these questions are very common at many smaller companies. What do you do when you dont know the answer?If you dont know the answer to a question about the Java language, try to figure it out by doing the following (1) Think about what other langua ges do. (2) Create an example of the scenario. (3) Ask yourself how you would handle the scenario if you were designing the language. Your interviewer will likely be equallyor moreimpressed if you

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.