Presentation given at University of Waterloo to help students prepare, know what to expect and perform well on coding interviews at the top technology companies
interview you! - They are not there to fail you. They need and want more teammates. They want you to pass! - They want to enjoy the interview. Have good discussions, maybe learn something new, maybe teach you something. The Interviewer POV
you know the programming language? - Are you coachable? - How familiar and efficient are you with the tools? - Do you know algorithms? What are they looking for?
you know the programming language? - Are you coachable? - How familiar and efficient are you with the tools? - Do you know algorithms? - Can you code? Recursion? Iteration? Data structures? What are they looking for?
you know the programming language? - Are you coachable? - How familiar and efficient are you with the tools? - Do you know algorithms? - Can you code? Recursion? Iteration? Data structures? - Code style? Naming? Strategy? What are they looking for?
the coding problem 05..15: Discussing algorithm and possible solutions 15..55: Coding the solution 55..60: Candidate’s turn to ask questions Coding Interview Structure
Unicode? - Do we expect the input to be very large? - Do we expect average string length to be large? - What if there is a tie? - Is null or empty input expected? Questions to Ask
it and quickly explain how the algorithm works. “We can compare each word to every other word and keep track of the largest common prefix found and its length” The Algorithm
to get good at algorithms is practicing! - Always ask questions such as: - Sorting the input helps? - What data structures could help? - Set? Hashmap? Tree? - Can I collect data to help in a first pass? Can we do better?
= new StringBuilder(); for (int i = 0; i < left.length() && i < right.length(); i++) { if (left.charAt(i) != right.charAt(i)) break; resultBuilder.append(left.charAt(i)); } return resultBuilder.toString(); } Brute Force
Map<String, Integer> allPrefixes = new LinkedHashMap<>(); for (int i = 0; i < words.length; i++) { String word = words[i]; StringBuilder prefixBuilder = new StringBuilder(); for (int j = 0; j < word.length(); j++) { // Store the prefix and count. See next } } return maxPrefix; } Using Hashmap
TreeNode root = new TreeNode(); for (int i = 0; i < words.length; i++) { TreeNode current = root; boolean matching = true; String word = words[i]; StringBuilder prefixBuilder = new StringBuilder(); for (int j = 0; j < word.length(); j++) { // Add each word to the tree keeping track of max prefix. (See next) } } return maxPrefix; } Using Trie (prefix tree)
solution, other solutions - Better ways to solve the problem. - Salary, Bonus, Options, Etc. Do ask: - About the company, team, the product, the job - The tools, the work environment, the mission - How the team prioritize tasks, etc Your turn to ask questions
to be calm and perform well. - Arrive early. Have your environment ready. Do not waste time on setup, that will take time away from your interview. Conclusion
to be calm and perform well. - Arrive early. Have your environment ready. Do not waste time on setup, that will take time away from your interview. - Communicate well and often. Ask questions. Keep talking. Conclusion
to be calm and perform well. - Arrive early. Have your environment ready. Do not waste time on setup, that will take time away from your interview. - Communicate well and often. Ask questions. Keep talking. - Have a strategy. Discuss options. If stuck, ask for advice. Conclusion
to be calm and perform well. - Arrive early. Have your environment ready. Do not waste time on setup, that will take time away from your interview. - Communicate well and often. Ask questions. Keep talking. - Have a strategy. Discuss options. If stuck, ask for advice. - Make sure you understand the problem. Write a simple test framework. Start with a test case. Conclusion
to be calm and perform well. - Arrive early. Have your environment ready. Do not waste time on setup, that will take time away from your interview. - Communicate well and often. Ask questions. Keep talking. - Have a strategy. Discuss options. If stuck, ask for advice. - Make sure you understand the problem. Write a simple test framework. Start with a test case. HAVE FUN! Conclusion