├── lessons ├── images │ ├── circular.png │ ├── What-I-Know.png │ ├── doubly-linked.png │ ├── insertion-sort.png │ ├── node-traversal-1.png │ ├── node-traversal-2.png │ ├── selection-sort.png │ └── linked-list-nodes.png ├── 09-Set-Map-Abstract-vs-Implement.md ├── 12-Things-Every-CS-Should-Know.md ├── 01-Arrays-Hashes.md ├── 00-Imposter-Syndrome.md ├── 05-Mergesort.md ├── 11-Whiteboarding-Recording.md ├── 02-ADTs-Stacks-Queues.md ├── 06-Array-vs-ArrayList.md ├── 10-Whiteboarding-Tips.md ├── 08-Trees.md ├── 03-Sorting-Efficiency.md ├── 04-Intro-to-Recursion.md └── 07-LinkedLists.md ├── interview-prep ├── problems │ ├── WB-2016-01-27.md │ └── WB-2016-01-27-solutions.md ├── README.md ├── interview-questions-data-structures.md ├── interview-questions-algorithms.md ├── interview-question-kal.md └── interview-questions-epic-list.md ├── solutions ├── rainbows-solution.rb └── mood-analysis-solution.rb └── README.md /lessons/images/circular.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudocrystal/cs-fundamentals/HEAD/lessons/images/circular.png -------------------------------------------------------------------------------- /lessons/images/What-I-Know.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudocrystal/cs-fundamentals/HEAD/lessons/images/What-I-Know.png -------------------------------------------------------------------------------- /lessons/images/doubly-linked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudocrystal/cs-fundamentals/HEAD/lessons/images/doubly-linked.png -------------------------------------------------------------------------------- /lessons/images/insertion-sort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudocrystal/cs-fundamentals/HEAD/lessons/images/insertion-sort.png -------------------------------------------------------------------------------- /lessons/images/node-traversal-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudocrystal/cs-fundamentals/HEAD/lessons/images/node-traversal-1.png -------------------------------------------------------------------------------- /lessons/images/node-traversal-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudocrystal/cs-fundamentals/HEAD/lessons/images/node-traversal-2.png -------------------------------------------------------------------------------- /lessons/images/selection-sort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudocrystal/cs-fundamentals/HEAD/lessons/images/selection-sort.png -------------------------------------------------------------------------------- /lessons/images/linked-list-nodes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sudocrystal/cs-fundamentals/HEAD/lessons/images/linked-list-nodes.png -------------------------------------------------------------------------------- /lessons/09-Set-Map-Abstract-vs-Implement.md: -------------------------------------------------------------------------------- 1 | # Set, Map, Abstraction vs Implementation 2 | 3 | ## Presentation 4 | + [Set, Map, Abstraction vs Implementation](https://docs.google.com/presentation/d/1ZHhSi_J1MUOBqv-DELG8Jt5aSUjsPiiTGXEp9vgHNaM/) 5 | -------------------------------------------------------------------------------- /lessons/12-Things-Every-CS-Should-Know.md: -------------------------------------------------------------------------------- 1 | # Things Every Computer Scientist Should Know 2 | 3 | ## Presentation 4 | + [Things Every Computer Scientist Should Know](https://docs.google.com/presentation/d/1Y4D8g9MHodhXOdt9wNCAZI9REi_VaZHTDu2Kbd0qyKs/) 5 | -------------------------------------------------------------------------------- /interview-prep/problems/WB-2016-01-27.md: -------------------------------------------------------------------------------- 1 | # Whiteboarding Role Play 2 | Blake (Amazon) joined us to provide a mock interview for C4 students. Instructors Charles and Jeremy played the roles of interviewees. They did not know the question beforehand, but they were asked to model a "bad" interview (Charles) and "good" interview (Jeremy). 3 | 4 | ## The problem 5 | Given an array of non-negative numbers, write a function to determine if any two numbers sum to 10. 6 | 7 | ## Sample solutions 8 | To see some sample solutions, click [here](WB-2016-01-27-solutions.md). 9 | -------------------------------------------------------------------------------- /solutions/rainbows-solution.rb: -------------------------------------------------------------------------------- 1 | require 'rainbow' 2 | require 'colorize' 3 | 4 | rainbow = [ 5 | { red: {r: 255, g: 0, b: 0}}, 6 | { orange: {r: 255, g: 127, b: 0}}, 7 | { yellow: {r: 255, g: 255, b: 0}}, 8 | { green: {r: 0, g: 255, b: 0}}, 9 | { blue: {r: 0, g: 0, b: 255}}, 10 | { indigo: {r: 75, g: 0, b: 130}}, 11 | { violet: {r: 143, g: 0, b: 255}}, 12 | ] 13 | 14 | # 15 | # def mix_colors(color1,color2) 16 | # mixed_color = {} 17 | # color1.each do |beam| 18 | # mixed_color[beam] = color1[beam] + color2[beam] 19 | # end 20 | # return mixed_color 21 | # end 22 | 23 | def colorize_text(text,rgb) 24 | puts Rainbow(text).color(rgb[:r],rgb[:g],rgb[:b]) 25 | end 26 | 27 | def print_rainbow(rainbow) 28 | rainbow.each do |color| 29 | colorize_text(color.first[0].to_s,color.first[1]) 30 | end 31 | end 32 | 33 | print_rainbow(rainbow) 34 | -------------------------------------------------------------------------------- /lessons/01-Arrays-Hashes.md: -------------------------------------------------------------------------------- 1 | # Reviewing Arrays and Hashes 2 | 3 | ## Activity 4 | 1. Describe an array. Give an example of a problem that you might use an array to solve. 5 | 2. Describe a Ruby hash. Give an example of a problem that you might use a Ruby hash to solve. 6 | 3. For each of the following, determine if you would use an array, a hash, or a combination of the two to solve the problem. Use your descriptions in #1 and #2 to justify your answer. 7 | - Count the frequency of letters used in a set of text. 8 | - Record attendance for 24 students for one day. 9 | - Track information for a single student (name, id, and address). 10 | - Track attendance for a cohort at Ada. 11 | - Track deposit and withdrawl amounts from a [petty cash fund](https://en.wikipedia.org/wiki/Petty_cash). 12 | - Represent a player's hand in [Texas Hold'em Poker](https://en.wikipedia.org/wiki/Texas_hold_%27em). 13 | - Represent a player's hand in [Go Fish](https://en.wikipedia.org/wiki/Go_Fish). 14 | -------------------------------------------------------------------------------- /lessons/00-Imposter-Syndrome.md: -------------------------------------------------------------------------------- 1 | # Imposter Syndrome 2 | 3 | ## Pre-Work 4 | Watch: 5 | + [she++ The Documentary - Good Girl Gone Geek](https://www.youtube.com/watch?v=DqrfPCGo2aQ) 6 | + [Feel Like You're Faking It? That Might Not Be a Bad Thing](http://lifehacker.com/5928639/feel-like-youre-faking-it-that-might-not-be-a-bad-thing) 7 | + [RailsConf 2014 - You are Not an Impostor by Nickolas Means (33 mins)](https://www.youtube.com/watch?v=l_Vqp1dPuPo) 8 | 9 | Think about this graphic:
10 | ![What I Know Ven Diagram](images/What-I-Know.png) 11 | 12 | ## Presentation 13 | + [Imposter Syndrome](https://docs.google.com/presentation/d/1xRZhUdaujm_gIkBB4E1uYsKFN3uMbIIrAxBYho0Z4d4/) 14 | 15 | ## Activities 16 | + Open discussion 17 | + Talk about exposing to others our "behind the scenes" and not letting them only see our "highlight reel" 18 | + It's ok if you don't have imposter syndrome! 19 | 20 | ## Challenge 21 | + Intentionally compliment one another during pair projects 22 | + Be willing to intentionally share struggles and broken code 23 | -------------------------------------------------------------------------------- /lessons/05-Mergesort.md: -------------------------------------------------------------------------------- 1 | # Mergesort 2 | 3 | ## Notes 4 | Mergesort is a recursive sorting algorithm. Mergesort works by splitting a list of elements in half repeatedly until reaching a list size of 1 or 0. Each half of the list is recursively sorted, and then merged back together to form the final sorted list. Like most recursive sorts, the merge sort has an algorithmic complexity of O(n log n). For the curious, [here's an explanation of Mergesort complexity](https://www.khanacademy.org/computing/computer-science/algorithms/merge-sort/a/analysis-of-merge-sort). 5 | 6 | ### Mergesort Algorithm 7 | 1. If the size of the array is larger than 1 8 | + Split the list in half. 9 | + MergeSort each half of the list. 10 | + Merge the sorted halves back together in order. 11 | 2. Otherwise, if the size of the array is not larger than 1 12 | + Assume an array of size 1 or 0 is in order. 13 | 14 | ### Mergesort Visualization 15 | Let's look at it in action: [Mergesort Visualization](https://www.cs.usfca.edu/~galles/visualization/ComparisonSort.html) 16 | -------------------------------------------------------------------------------- /interview-prep/README.md: -------------------------------------------------------------------------------- 1 | # Interview Prep 2 | I believe that Computer Science is largely pattern recognition and critical thinking. The more problems you see and try, the most easily you recognize patterns and are later able to apply them. 3 | 4 | ## Smaller Practice Problems (ruby) 5 | | Problems 6 | |:--------------------- 7 | | [sudocrystal/balanced-brackets](https://github.com/sudocrystal/balanced-brackets) 8 | | [sudocrystal/digit-match](https://github.com/sudocrystal/digit-match) 9 | | [sudocrystal/even-digits](https://github.com/sudocrystal/even-digits) 10 | | [sudocrystal/number-sorting](https://github.com/sudocrystal/number-sorting) 11 | | [sudocrystal/whiteboard-practice-1](https://github.com/sudocrystal/whiteboard-practice-1) 12 | | [sudocrystal/array-equals](https://github.com/sudocrystal/array-equals) 13 | | [sudocrystal/whiteboard-practice-2](https://github.com/sudocrystal/whiteboard-practice-2) 14 | | [sudocrystal/remove-all](https://github.com/sudocrystal/remove-all) 15 | | [sudocrystal/is-rotation](https://github.com/sudocrystal/is-rotation) 16 | | [sudocrystal/switch-nodes](https://github.com/sudocrystal/switch-nodes) 17 | | [sudocrystal/order-list](https://github.com/sudocrystal/order-list) 18 | -------------------------------------------------------------------------------- /interview-prep/interview-questions-data-structures.md: -------------------------------------------------------------------------------- 1 | # Interview Questions - Data Structures 2 | 3 | How is this data going to be accessed? Do we need to optimize for latency or space? 4 | 5 | + Parking Lot for monthly parking 6 | - Design a system where customers are assigned a specific spot 7 | - Write isFullyBooked() 8 | - Write assignSpot(name) 9 | - What if the spots have different types (like handicap, motorcycle, electric car)? 10 | + URL Autocomplete 11 | - Design a system that stores browser history of URLs 12 | - Write autocomplete(prefix) which returns all the URLs that could autocomplete with the given prefix 13 | + Gmail Suggested Email 14 | - When you write an email to a group of people, related people are suggested. How would you implement this feature? 15 | + Web Crawler 16 | - Design a system for a WebCrawler. The webcralwler will be provided millions of URLs. Each webpage needs to be downloaded and then parsed for more URLs. If more URLs are found then they should also be downloaded and parsed. 17 | - Does your solution scale to handle millions of URLs? 18 | - What are the bottle necks in the system? How will you resolve them? 19 | + Vending Machine 20 | - Design a system for a vending machine. 21 | + Nightclub Bouncer 22 | - Design a system for admitting people into a nightclub 23 | - Consider VIPs and parties larger than 1 24 | - Only 500 people may be inside at a time (per fire code, of course) 25 | + Website User Preferences 26 | - Design a system to store customer preferences (like default language, favorite color, shoe size) where every attribute will have a default value if not set by the user 27 | - Write getAttribute(name) 28 | - Write getAllAtrributes() 29 | - What if we want to change the default value of attributes that are not set by customers? 30 | 31 | -------------------------------------------------------------------------------- /lessons/11-Whiteboarding-Recording.md: -------------------------------------------------------------------------------- 1 | # Recording yourself Whiteboarding 2 | 3 | ## Time Schedule 4 | - 20 mins first partner recorded interview 5 | - 20 mins second partner recorded interview 6 | - 15 mins to watch your own recording 7 | - 15 mins debrief with your partner about what you observed 8 | - 5 mins self-assessment/reflection survey 9 | 10 | ## Recording 11 | Use Photobooth on your own computer to record your interview. You do not need to share this video with anyone, and yes, you can delete it right after if you want. 12 | 13 | ## Questions 14 | 15 | ### Partner 1 (choose to ask one of the two) 16 | View markdown when you are ready to ask 17 | 21 | 22 | ### Partner 2 (choose to ask one of the two) 23 | View markdown when you are ready to ask 24 | 28 | 29 | ## Examples of things you are looking for in your recorded playback 30 | - Is your writing legible? 31 | - Do you block the write board when you talk? 32 | - Do you have long pauses? Or are they shorter in playback than they are in your head? 33 | - Do you appear confident? 34 | - How is your eye contact and demeanor? 35 | - Do you mumble? 36 | - Do you talk to the whiteboard or the interviewer? 37 | - Are you unecessarily appologizing? 38 | - Are you saying things like "I don't know where this is going" instead of something like "I might rethink this later, but I'll start here"? 39 | - Are you using technical describing words appropriately or are you saying a lot of "this", "that", etc? 40 | - Are you making any weird faces? 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CS FUN(damentals) Series 2 | This series was developed to teach CS fundamentals to new programmers in a condensed amount of time. The major goal of these lessons is to teach jargon and high-level concepts so that new programmers can recognize "mumbo jumbo" in the industry and have a mental model of concepts to properly communicate with their teammates. 3 | 4 | ## Table of Contents 5 | 6 | _Most assignments below contain a `solutions` branch_ 7 | 8 | | Lesson | Ruby Assignment 9 | |:-------------------------- |:--------------------- 10 | | [Imposter Syndrome](lessons/00-Imposter-Syndrome.md) | 11 | | [Arrays and Hashes](lessons/01-Arrays-Hashes.md) | 12 | | [ADTs, Stacks and Queues](lessons/02-ADTs-Stacks-Queues.md) | [sudocrystal/stacks-queues](https://github.com/sudocrystal/stacks-queues) 13 | | [Sorting and Efficiency](lessons/03-Sorting-Efficiency.md) | [sudocrystal/big-o](https://github.com/sudocrystal/big-o) 14 | | [Intro to Recursion](lessons/04-Intro-to-Recursion.md) | [sudocrystal/recursion-tracing](https://github.com/sudocrystal/recursion-tracing) 15 | | [Writing Mergesort](lessons/05-Mergesort.md) | [sudocrystal/mergesort](https://github.com/sudocrystal/mergesort) 16 | | [Native Array vs Array List](lessons/06-Array-vs-ArrayList.md)| [sudocrystal/list-implementations](https://github.com/sudocrystal/list-implementations) 17 | | [Linked List](lessons/07-LinkedLists.md) | [sudocrystal/list-implementations](https://github.com/sudocrystal/list-implementations) 18 | | [Trees](lessons/08-Trees.md) | [sudocrystal/tree-practice](https://github.com/sudocrystal/tree-practice) 19 | | [Sets & Maps](lessons/09-Set-Map-Abstract-vs-Implement.md) | 20 | | [Whiteboarding Tips](lessons/10-Whiteboarding-Tips.md) | [Whiteboarding Recording](lessons/11-Whiteboarding-Recording.md) 21 | | [Things Every CS Should Know](lessons/12-Things-Every-CS-Should-Know.md) | 22 | 23 | ## Powerpoint Presentations 24 | Link to powerpoint presentations: [here](https://drive.google.com/drive/folders/0B6DpS0ihYV31Rk1BakZMQ09FWk0?usp=sharing) 25 | -------------------------------------------------------------------------------- /lessons/02-ADTs-Stacks-Queues.md: -------------------------------------------------------------------------------- 1 | # ADTs / Stacks / Queues 2 | 3 | ## Presentation 4 | + [ADTs / Stacks / Queues](https://docs.google.com/presentation/d/1LgR-wo4Niae31EY2yrT5fQHs_jeliW7JxB_1B7wXQBE/) 5 | 6 | ## Notes 7 | 8 | ### Data Structures and Abstract Data Types (ADTs) 9 | 10 | In computer science, a data structure is a particular way of organizing data in a computer so that it can be used efficiently. Data structures can implement one or more particular abstract data types (ADT), which specify the operations that can be performed on a data structure and the computational complexity of those operations. In comparison, a data structure is a concrete implementation of the specification provided by an ADT. 11 | 12 | - ADT - Rules that we must follow when interacting with data. 13 | - Data Structure - An implementation of an ADT; something you can actually interact with. 14 | 15 | Different kinds of data structures are suited to different kinds of applications, and some are highly specialized to specific tasks. 16 | 17 | ### Stacks and Queues 18 | Stacks and Queues are special cases of an ordered list. 19 | 20 | #### Stack 21 | A stack is an ordered list where all insertions and removals are made only from one end. This end is usually referred to as ‘top’. This structure is similar to a stack of lunch trays. The first tray you put on the stack is the last tray you take off the stack. Likewise, the last tray you put on the stack is the first tray you take off the stack. This process is called LIFO, last in is the first out. 22 | 23 | #### Queue 24 | A queue is an ordered list where insertions are made at one end (usually referred to as the back) and removals are made from the other end (usually referred to as the front). This structure is similar to a lunch line. The first person to enter the line is the first person to exit the line. Likewise, the last person to enter the line is the last person to exit the line. This process is called FIFO, first in is the first out. 25 | 26 | ## Comprehension Questions 27 | 28 | 1. What is an ADT? 29 | 1. What is a stack? 30 | 1. What are the 5 methods in Stack and what does each do? 31 | 1. What is a queue? 32 | 1. What are the 5 methods in Queue and what does each do? 33 | -------------------------------------------------------------------------------- /solutions/mood-analysis-solution.rb: -------------------------------------------------------------------------------- 1 | $feelings = { 2 | happy: %w(yay good great), 3 | sad: %w(terrible awful horrible) 4 | } 5 | 6 | # Used these 2 method for my own testing... 7 | ######################################################### 8 | def generate_entry 9 | all_the_feels = $feelings.values.flatten 10 | entry = "%02d/%02d " % [rand(12)+1,rand(28)+1] 11 | 10.times do 12 | if rand(4) < 1 13 | entry += all_the_feels[rand(all_the_feels.length)] 14 | else 15 | entry += "---" 16 | end 17 | entry += " " 18 | end 19 | return entry 20 | end 21 | 22 | def generate_text 23 | text = [] 24 | 10.times do 25 | text.push(generate_entry) 26 | end 27 | return text.sort 28 | end 29 | ######################################################### 30 | 31 | def overall_mood(entries) 32 | return nil if entries.length == 0 33 | emoticons = Hash.new(0) 34 | entries.each do |entry| 35 | emoticon = analyze_mood(entry) 36 | emoticons[emoticon] += 1 37 | end 38 | return emoticons.max_by{|k,v| v}[0] 39 | end 40 | 41 | def happy_days(entries) 42 | moody_days(entries,":-)",3) 43 | end 44 | 45 | def moody_days(entries,emoticon,days) 46 | count = 0 47 | entries.each do |entry| 48 | count += 1 49 | if analyze_mood(entry) == emoticon 50 | days -= 1 51 | end 52 | return count if days == 0 53 | end 54 | return nil 55 | end 56 | 57 | def strip_punctuation(s) 58 | s.gsub!(/[.!,#]/,"") 59 | return s 60 | end 61 | 62 | def analyze_mood(words) 63 | words = strip_punctuation(words) 64 | happy = 0 65 | sad = 0 66 | words.downcase! 67 | words.split(" ").each do |word| 68 | if $feelings[:happy].include? word 69 | happy += 1 70 | elsif $feelings[:sad].include? word 71 | sad += 1 72 | end 73 | end 74 | return ":-)" if happy > sad 75 | return ":-(" if happy < sad 76 | return ":-|" 77 | end 78 | 79 | text = [ 80 | "03/01 I'm having a terrible horrible no good day.", 81 | "03/13 Yesterday was horrible, but today is great! Yay!", 82 | "04/02 Sad Panda. #terribleday", 83 | "04/15 Hello World, today is fabulous! #yay", 84 | "05/01 Great! Yay! Good! Yay! Happy. Happy.", 85 | "05/11 Yay, yay, yay! I'm having a awfuly great day." 86 | ] 87 | # text = generate_text 88 | # text.each do |t| puts t end 89 | 90 | text.each do |entry| 91 | puts entry[0..5] + " " + analyze_mood(entry) 92 | end 93 | 94 | puts "It takes #{happy_days(text)} entries for 3 happy days to occur" 95 | puts "The most common mood is #{overall_mood(text)}" 96 | -------------------------------------------------------------------------------- /lessons/06-Array-vs-ArrayList.md: -------------------------------------------------------------------------------- 1 | # Native Array vs Array List 2 | 3 | ## Presentation 4 | + [Array vs LinkedList](https://docs.google.com/presentation/d/15_ss5WjvPxGoMb0-xjUAQJ0WraggY-bgxu1PappJrPk/) 5 | 6 | ## Notes 7 | In short, Ruby Arrays are magical and have characteristics that most programmers would not associate with an "array" (which has an implied "native" in front when used in conversation). Instead, Ruby's Arrays are similar to ArrayList in other languages (Java, C++, C#, etc) and have added functionality. 8 | 9 | ### Native Arrays 10 | Native Arrays are: 11 | + fixed in size 12 | + contiguous blocks of memory 13 | + have no methods 14 | 15 | You must specify the size when you create a native array. This size determines how large the contiguous block of memory needed must be (number of bytes for the data * number of elements to be stored). Contiguous memory means that the entire block of information is stored in memory all in a row. The fact that the information is contiguous allows us to have O(1) operations when working with the array in many cases. 16 | 17 | Information in native arrays is accessed by indexing the array (e.g. `a[0]` or `a[i]`) and no methods are called on a native array (e.g. you cannot say `a.shuffle` or `a.first`). 18 | 19 | So if we wanted to create an array that holds ["apple","banana","pear"] and then becomes ["apple","banana",""], we might say: 20 | 21 | ```ruby 22 | a = ["","",""] 23 | a[0] = "apple" 24 | a[1] = "banana" 25 | a[2] = "pear" 26 | puts a.length # would return 2 27 | 28 | # and then 29 | a[2] = "" 30 | puts a.length # would return 3 31 | ``` 32 | 33 | ### Array Lists 34 | A Ruby Array is like an ArrayList in other languages. ArrayLists are wrapper classes that use a native array as the underlying structure, but give added functionality by providing methods that allow you to interact with the native array without knowing all the details of what happens. 35 | 36 | Array Lists: 37 | + do not have a fixed size (they resize the native array inside when needed) 38 | + still use contiguous blocks of memory (because the information is _actually_ stored in a native array, but this is hidden) 39 | + provide methods to call on an array (e.g. `add`, `delete`, `include?`, `size`, `max`) 40 | 41 | So if we wanted to create an ArrayList that holds ["apple","banana","pear"] and then becomes ["apple","banana",""], we might say: 42 | 43 | ```ruby 44 | a = ArrayList.new 45 | a.add("apple") 46 | a.add("banana") 47 | a.add("pear") 48 | puts a.size # would return 3 49 | 50 | # and then 51 | a.delete("pear") 52 | puts a.size # would return 2 53 | ``` 54 | 55 | ### Interface vs Implementation 56 | -------------------------------------------------------------------------------- /lessons/10-Whiteboarding-Tips.md: -------------------------------------------------------------------------------- 1 | # Practicing Interview Problems 2 | 3 | | TASKS 4 | |------------------------------------------------- 5 | | 1. Read Articles 6 | | 2. Come up with some example answers to chitchat questions. 7 | | 3. Practice whiteboarding in front of a peer/partner 8 | 9 | Technical interviews can be stressful, but like most anything else, they are a learned, practiced skill. DON'T PANIC! Technical interviews are not necessarily about evaluating the validity of your solution, but often are more about evaluating a candidate's technical communication skills and problem solving approach. 10 | 11 | ## 1. Read these articles 12 | + [Big O Notation: Using not-boring math to measure code's efficiency](https://www.interviewcake.com/article/big-o-notation-time-and-space-complexity) 13 | + [Coding Interview Tips: How to get better at technical interviews without practicing](https://www.interviewcake.com/article/coding-interview-tips) 14 | 15 | ## 2. Chit-chat Questions 16 | Come up with 1 example for each of the following: 17 | 1. example of an interesting technical problem you solved 18 | 1. example of an interpersonal conflict you overcame 19 | 1. example of leadership or ownership 20 | 1. story about what you should have done differently in a past project 21 | 22 | ## 3. Practice 23 | Practice solving a problem in front of another person and talking out your solutions. This person can be a peer/partner/friend and they can be technical or not technical. Your goal is to spend 15-20 minutes tackling a problem in front of someone else. Ideally on a whiteboard, but if you don't have a whiteboard, on paper. Have the person you are working with read you a question from [here](../interview-prep/interview-questions-algorithms.md). **Don't stress about the solution! Make sure you understand the problem, state your assumptions, talk out loud!** 24 | 25 | Technical Questions: Problem Solving approach 26 | 27 | 1. **Understand the Probem** 28 | * Ask your interviewer questions 29 | * Create a specific example - given inputs and expected output 30 | 31 | 1. **Devise a plan** 32 | * What is the simplest approach that you can think of? 33 | * Have you solved any similar problems 34 | * Outline your approach in plain English 35 | * State your assumptions and ask more questions if needed 36 | 37 | 1. **Execute the plan** 38 | * Turn your plain language description into code 39 | * Write whiteboard code slowly 40 | * Ask questions / call out places where you don't know the syntax 41 | 42 | 1. **Check your answer** 43 | * Run examples through your whiteboard code 44 | * Can you improve your solution? Red, Green, Refactor! 45 | -------------------------------------------------------------------------------- /lessons/08-Trees.md: -------------------------------------------------------------------------------- 1 | # Trees 2 | 3 | ## Presentation 4 | + [Trees](https://docs.google.com/presentation/d/1tGOJaS8DIsFoHpev-RxfVV3XyJeLm2h3p2pumZPF_00/) 5 | 6 | ## Notes 7 | 8 | ### Tree Vocabulary 9 | 10 | - a **node** is where one value in a tree is stored. Each node contains a value and references to its child nodes. 11 | - the **root** of a tree is the topmost node, or the node in the tree with no parents. 12 | - the **parent** of a node is the one which references the given node directly. 13 | - a node's **siblings** are nodes which share the same direct parent. 14 | - a **descendant** of a node is a node which can be reached directly or indirectly from the given node. 15 | - an **ancestor** of a node is a node which refers directly or indirectly to the given node. The root node is the ancestor for all nodes in the tree. 16 | - a **leaf node** is a node with no descendants. 17 | - an **edge** of a tree is a connection between nodes. 18 | - a **path** in a tree is a series of nodes that can be traversed from one node to another. 19 | - the **level** of a node is 1 + the number of nodes between the given node and the root. 20 | - the **height** of a node is the longest path between that node and one of it's leaf descendants. 21 | - the **depth** of a node is the number of edges from the root to the node. 22 | - **traversing** through a tree is navigating through a tree 23 | 24 | ### Traversing a Tree 25 | There are three common ways to iterate through a tree called a `traversal`, in-order traversal, pre-order traversal and post-order traversal. 26 | 27 | - In an **inorder traversal** we traverse the left child first then the parent and then traverse the right child. Inorder Traversal is usually only applied to binary search trees. 28 | - A **preorder traversal** we visit the current node first and then traverse the left subtree and then traverse the right subtree. 29 | - A **post-order** traversal involves traversing the right and left subtrees and then visiting the current node. 30 | 31 | ### Special Trees 32 | 33 | - a **binary tree** is a tree in which each node has at most 2 children (bi implies 2) 34 | - a **full binary tree** is a binary tree where every node except the leaves has two children. 35 | - a **full tree** is a binary tree where every level at every level except the bottom-most level has the maximum number of children (2). 36 | - a **Binary Search Tree** is a binary tree where the left child of a node is always smaller than it's parent and every right-child of a node is larger than it's parent. 37 | - a **subtree** is the tree formed by the left or right children of a given node. 38 | 39 | ### Binary Search Trees 40 | Binary Search Trees have a few differences compared to linked lists. 41 | 42 | Superficially 43 | - Each node can point to up to two (hence "bi-" prefix) other nodes 44 | - There is no single end to a tree, rather many leaves 45 | 46 | Performance: 47 | - It's potentially much faster to find elements in a Binary Search Tree 48 | - Each node is slightly bigger in terms of memory footprint and there is some overhead involved in keeping the tree balanced 49 | 50 | ## Resources 51 | [A Good Stack-Overflow Post comparing Trees & Linked Lists](http://stackoverflow.com/a/270094/6840529) 52 | -------------------------------------------------------------------------------- /lessons/03-Sorting-Efficiency.md: -------------------------------------------------------------------------------- 1 | # Sorting and Efficiency 2 | 3 | ## Presentation 4 | + [Sorting and Efficiency](https://docs.google.com/presentation/d/1pi7d1drWIZ1dAU-bnP-r7X2fscYdeSOVsfigoNE-cc8/) 5 | 6 | ## Notes 7 | 8 | ### Selection Sort 9 | The selection sort works by selecting the smallest unsorted item remaining in the list, and then swapping it with the item in the next position to be filled. 10 | 11 | ![Selection Sort Example](images/selection-sort.png) 12 | 13 | Selection sort has a complexity of O(n^2). 14 | 15 | ### Insertion Sort 16 | The insertion sort works by inserting each item into its proper place in a final list. The simplest implementation of this requires two list structures - the source list and the list into which sorted items are inserted. To save memory, most implementations use an in-place sort that works by moving the current item past the already sorted items and repeatedly swapping it with the preceding item until it is in place. 17 | 18 | ![Insertion Sort Example](images/insertion-sort.png) 19 | 20 | The insertion sort has a complexity of O(n^2). 21 | 22 | ### Algorithm Efficiency 23 | An _efficient algorithm_ is one that runs as fast as possible and requires as little computer memory as possible. You often have to settle for a trade-off between these two goals, compromising memory to make things faster, or speed to use less memory. 24 | 25 | There are three ways of expressing performance: Best-case, worst-case and average case. 26 | 27 | Consider the task of performing a sequential search on some sort of list, i.e. an array. Best-case would be that your target value was found in the first element. Worst-case would be that the value was not there at all (so all elements would have to be compared and tested, including the last). Average-case would be mid-way between the two. 28 | 29 | *In Computer Science, we care about worst case, which we call Big-O.* 30 | 31 | ### Order Breakdown 32 | - *O(1)* is the no-growth curve. An O(1) algorithm's performance is conceptually independent of the size of the data set on which it operates. Array element access is O(1). 33 | - *O(log N)* means that the data set size does affect the efficiency of the algorithm, but only in a logarithmic fashion. The key thing to note is that log (base 2) N grows slowly. Doubling N has a relatively small effect. Logarithmic curves flatten out nicely. 34 | - *O(N)* says that the algorithm's performance is directly proportional to the size of the data set being processed. Scanning an array takes O(N) time. 35 | - *O(N^2)* says that the algorithm's performance is proportional to the square of the data set size. This happens when the algorithm processes each element of a set, and that processing requires another pass through the set. 36 | 37 | ### Nuances 38 | - Usually when an algorithm's growth rate is a mix of orders, the dominant order is shown, and the rest are dropped. O(N^2 + N) would be shortened to O(N^2). 39 | - Likewise, constants are dropped. Constants only shift our graph slightly, but do not affect the overall look of the graph by much. O(2N) is shortened to O(N). O(1⁄2 N) is shortened to O(N). 40 | 41 | ### Complexity Analogy 42 | This stackoverflow answer does a great job in illustrating Big O notation for algorithm complexity. The author has a use case related to phone books for each level of complexity: 43 | 44 | - *O(1)* – Find a random person’s phone number by flipping open any page in the phone book. 45 | - *O(log n)* – Given a person’s name, find the corresponding phone number (This is a binary search for a person’s phone number). 46 | - *O(n)* – Find all people whose phone numbers contain the digit “5″. 47 | - *O(n log n)* – Sort a phone book’s pages by looking at the first name on each page. 48 | -------------------------------------------------------------------------------- /interview-prep/interview-questions-algorithms.md: -------------------------------------------------------------------------------- 1 | # Interview Questions - Algorithms 2 | 3 | ## Questions 4 | ### Strings 5 | 1. Strip whitespace from a string in-place e.g. 6 | 7 | ```ruby 8 | "H e llo W orl d" 9 | ``` 10 | becomes 11 | ```ruby 12 | "HelloWorld" 13 | ``` 14 | 15 | 1. Remove duplicate chars from a string e.g. `"AAA BBB"` -> `"A B"` 16 | 1. Find the first non-repeating character in a string e.g. `"ABCA"` -> `B` 17 | 1. Reverse a string e.g. `"Hello"` --> `"olleH"` 18 | 1. Reverse words in a string (words are separated by one or more spaces). e.g. `"This is stuff"` --> `"stuff is This"` _Extra fun: Do it in-place._ 19 | 20 | ### Arrays 21 | 1. You are given an unsorted array with integers between 1 and 1,000,000. One integer is in the array twice. Determine which one. _Extra fun: Do it without sorting._ 22 | 1. You are given an unsorted array containing all integers between 1 and 1,000,000. One integer is missing. How can you determine which one? _Extra fun: Can you think of a way to do it by iterating through the array only once, without sorting?_ 23 | 1. Return the sum of the two largest integers in an array e.g. Given `[19, 4, 2, -19, 100, 9]`, return `119` (100 + 19) 24 | 1. Return the largest sum of contiguous integers in the array e.g. Given `[-10, 2, 3, -2, 0, 5, -15]`, the largest sum is `8` (2 + 3 + -2 + 0 + 5) 25 | 26 | 55 | -------------------------------------------------------------------------------- /lessons/04-Intro-to-Recursion.md: -------------------------------------------------------------------------------- 1 | # Recursion 2 | 3 | ## Presentation 4 | + [Recursion](https://docs.google.com/presentation/d/1EpTMj-NEZQI6jiOlXu5CmebSzysu8b73ZyNHCeevLGI/) 5 | 6 | ## Notes 7 | So far we have only learned how to solve problems iteratively using loops. We will now learn how to solve problems recursively by having a method call itself. 8 | 9 | A geeky definition of recursion is as follows: 10 | Recursion – see Recursion. 11 | 12 | ### Parts of a recursive algorithm 13 | 14 | A Recursive algorithm has two parts: 15 | 1. If the problem is easy, solve it immediately. 16 | 2. If the problem can't be solved immediately, divide it into smaller problems, then: Solve the smaller problems by applying this procedure to each of them. 17 | 18 | We call a problem that can be solved immediately a *base case* and a problem that divides the problem into a smaller problem a *recursive case*. 19 | 20 | So a recursive algorithm is really made up of: 21 | - At least one base case. 22 | - At least one recursive case. 23 | 24 | ### An example: factorial 25 | 26 | Let’s consider the mathematical concept factorial. In order to calculate a factorial (!), you multiply all the numbers from n down to 1, knowing that 1! = 1, 0! = 1. 27 | 28 | So, 29 | 5! = 5 * 4 * 3 * 2 * 1 30 | 10! = 10 * 9 * 7 * 6 * 5 * 4 * 3 * 2 * 1 31 | 3000! = 3000 * 2999 * 2998 * 2997 * … * 3 * 2 * 1 32 | 33 | We could also state 5! = 5 * 4 * 3 * 2 * 1 as: 34 | 5! = 5 * 4! 35 | 4! = 4 * 3! 36 | 3! = 3 * 2! 37 | 2! = 2 * 1! And we know 1! = 1 38 | 39 | So, in general: 40 | n! = n * (n-1) * (n-2) * (n-3) * … * 1 41 | 42 | Which broken down to model a recursive algorithm is: 43 | - If simple, Solve it immediately --> 1! = 1, 0! = 1 44 | - If not simple, solve a small piece and then try to solve the rest --> n! = n * (n-1)! 45 | 46 | If we were to divide this concept into a recursive definition, we might say: 47 | - If n = 1, return 1 48 | - If n > 1, return n * (n-1)! 49 | 50 | We call this the *static view* of a recursive method. Basically the static view is the mathematical way of looking at a recursive problem. 51 | 52 | ### Code it 53 | 54 | Once we know what the base case and the recursive cases of a problem are, we can then write the code. 55 | 56 | Given: 57 | Factorial 58 | - factorial(1) = 1 59 | - factorial(n) = n * factorial(n-1) 60 | 61 | We can code this as: 62 | ``` 63 | def factorial(n) 64 | if n == 1 65 | return 1 66 | else 67 | return n * factorial(n-1) 68 | end 69 | end 70 | ``` 71 | 72 | or 73 | 74 | ``` 75 | def factorial(n) 76 | return 1 if n == 1 77 | return n * factorial(n-1) 78 | end 79 | ``` 80 | 81 | ### Trace through an example 82 | When we follow what's happening as we make a recursive call, it can be hard to keep track of variables and results since there can be many activation records (or method calls). I like to use "bubbles" to show the activation calls (the activation stack). One day I'll add pictures here of that. For now, see the video. 83 | 84 | ### Why (or why not) Recursion? 85 | 86 | Some problems are naturally recursive. If you can easily identify a base case and a recursive case, then a recursive method might be easier to write and understand. Sometimes a recursive method just makes more sense than an iterative method. All recursive methods can be written iteratively. 87 | 88 | However, recursive methods come at a cost. Recursive methods use a lot of memory because each activation requires more memory to be allocated for each parameter and local variable. 89 | 90 | ### Writing a recursive method 91 | 92 | When writing a recursive method, try the following: 93 | - Think about how you can reduce the problem to one or more simpler sub-problems of the same form. 94 | - Think about what information you need to give to the sub-problems (the parameters). 95 | - Think about what information you want back from the sub-problems (the return type). 96 | - Write the method header. 97 | - Think about the base case: When is the answer so simple that we know the answer without recursing? 98 | - Think about the recursive case: How are we going to break the problem into a smaller problem (by calling out method again) and get closer to the base case? 99 | Write the code. 100 | - Write a method specification (like the static view of the problem) that explains exactly what it will do in terms of the parameters. Include any preconditions. 101 | - Test out your code with several different cases. 102 | -------------------------------------------------------------------------------- /lessons/07-LinkedLists.md: -------------------------------------------------------------------------------- 1 | # Linked Lists 2 | 3 | ## Presentation 4 | + [Linked Lists](https://docs.google.com/presentation/d/19hF2PZMd8_LHyWtg4sXtMLJcscuZyySQ62lMY0N_mWQ/) 5 | 6 | ## Notes 7 | A Linked List is a dynamic data structure that allows you to create a storage space that is capable of growing or shrinking in size. Additionally, information stored in a Linked List is stored **non-contiguously** and **space is only used as it is needed**. This contrasts a native array, where information is stored contiguously in memory and the size is fixed when instantiated. 8 | 9 | A linked list is **a collection of nodes**. 10 | 11 | A node typically has two parts: 12 | 1) data (a single String, hash, fixnum, Object, etc...) 13 | 2) a pointer to another node or `nil` (a pointer without a target – essentially goes nowhere) 14 | 15 | When we visualize a linked list, our drawings usually look like this: 16 | 17 | ![Visualization of Nodes](images/linked-list-nodes.png) 18 | 19 | What you may be wondering is how we can access the data in an individual node of a linked list. **One limitation of a Linked List is that we have to access the data in linear order.** So in order to access data, we must start at the beginning of the list (the "**head**") and move down the list until we run out of nodes, using a **temporary pointer to keep track of our current position in the list**. 20 | 21 | ![Node traversal 1/2](images/node-traversal-1.png) 22 | 23 | So if we had a linked list like the one above, in order to print all the elements in the linked list, we might follow a procedure like: 24 | 25 | ``` 26 | Create variable TRAVERSE to point at the node linky 27 | WHILE TRAVERSE isn't nil (the end of the linked list) 28 | Print out the data stored in TRAVERSE's current node. 29 | Move TRAVERSE to the next node 30 | END WHILE 31 | ``` 32 | 33 | ![Node traversal 2/2](images/node-traversal-2.png) 34 | 35 | ### Different Types of Linked Lists 36 | There are different types of linked lists. 37 | 38 | The most basic looks like what is describe above and is called a **singly linked list**. Each node has exactly one successor node, except for the last node, which points to `nil`. Each node has exactly one predecessor node, except for the first node (the "head" or "front" of the list), which has no predecessor. 39 | 40 | There are also **doubly linked lists**, which are much like singly linked lists, except that they also point backwards. So doubly linked lists have both a `next` and a `prev` pointer. 41 | 42 | ![Doubly Linked List](images/doubly-linked.png) 43 | 44 | There are also **circularly linked lists**, which can either be singly or doubly linked, but the end of the list points back to the first item in the list. In this case, every node has exactly one predecessor and one successor node. 45 | 46 | ![Circular List](images/circular.png) 47 | 48 | ### A closer look at Linked List methods 49 | Given that every `Node` should have `data` and `next` (sometimes these exact variable names are different), let's look at what pseudocoding an `add` and `delete` method might look like: 50 | 51 | ADD 52 | ``` 53 | IF the linked list is empty 54 | create the first node and give it the value passed in 55 | update size, if tracking 56 | ELSE 57 | (traverse to the end of the list and insert a new node with the passed value by:) 58 | create a pointer (current) to the head node 59 | 60 | WHILE current has a node after it 61 | set current to be the node after current 62 | END WHILE 63 | 64 | add a new node to the end of the list (now current) 65 | update size, if tracking 66 | END IF/ELSE 67 | ``` 68 | 69 | DELETE 70 | ``` 71 | IF the list is empty 72 | return nil/null --> something to exist the method 73 | END IF 74 | IF the data you want to delete is in the head node 75 | make head point to head's next 76 | update size, if tracking 77 | ELSE 78 | create a pointer (previous) to point at head 79 | create a pointer (current) to point at head's next 80 | 81 | WHILE there's a current node to process AND current's data isn't what we want to delete 82 | set previous to previous's next 83 | set current to current't next 84 | END WHILE 85 | 86 | IF the current node isn't nil/null (meaning a node was found to delete) 87 | (jump over the node to be deleted by:) 88 | setting previous's next to current's next 89 | update size, if tracking 90 | END IF 91 | END IF/ELSE 92 | ``` 93 | 94 | PRINT (ruby: to_s) 95 | ``` 96 | IF the list is empty 97 | return "[]" 98 | END IF 99 | 100 | create a string to hold the string version of the list (toReturn) 101 | (traverse through the list till you hit the "nil" at the end by:) 102 | create a pointer (current) to point at head 103 | 104 | WHILE there's a current node to process 105 | add the current node's data to toReturn + "-->" 106 | set current to current't next 107 | END WHILE 108 | 109 | remove the last "-->" 110 | return the built string (toReturn) 111 | ``` 112 | 113 | ### Adding to a Linked List 114 | 115 | The add method outlined above always adds to the end of the list. Is this the most efficient way to add to a Linked List? (A: no). Because adding to the end of a list requires us to visit every node in the list, it is O(n) to add to the end of a list. 116 | 117 | But what if we added to the front of the list instead? We could do the following, which would be constant time because we wouldn't need to traverse through the linked list at all. 118 | 119 | ADD O(1) 120 | ``` 121 | set head equal to a new node(passed value, old head) 122 | ``` 123 | 124 | Both of these methods maintain some sort of ordering based on how the data is inserted into the linked list. But what if we wanted our list to maintain numerical sorted order? Then what?! Perhaps: 125 | 126 | ADD (maintaining sorted order) 127 | ``` 128 | IF the linked list is empty 129 | create the first node and give it the value passed in 130 | update size, if tracking 131 | ELSE IF the data to be inserted belongs in front of the head node 132 | set head equal to a new node(passed value, old head) 133 | ELSE 134 | create a pointer (current) to the head node 135 | 136 | WHILE current has a node after it && current's next's data is smaller than the data passed 137 | set current to be the node after current 138 | END WHILE 139 | 140 | set current's next to be a new node(passed value, old current's next) 141 | END IF/ELSE 142 | update size, if tracking 143 | ``` 144 | -------------------------------------------------------------------------------- /interview-prep/problems/WB-2016-01-27-solutions.md: -------------------------------------------------------------------------------- 1 | # Whiteboarding Role Play 2 | 3 | ## The problem 4 | Given an array of non-negative numbers, write a function to determine if any two numbers sum to 10. 5 | 6 | ## Videos 7 | Video PW is octothorp 8 | + Charles: 9 | + Jeremy: https://vimeo.com/153441061 10 | + Crystal: https://vimeo.com/153441144 11 | 12 | ## Sample solutions 13 | Solutions written by Crystal -- probably not error free ;) 14 | 15 | ``` java 16 | import java.util.Arrays; 17 | import java.util.HashMap; 18 | 19 | public class WhiteboardProblems 20 | { 21 | public static void main(String[] args) 22 | { 23 | int[] numbers = {1,228,9,4,80,10}; 24 | assert bruteForce(numbers) == true : "BF: Uh roh. Didn't find 1,9 = 10"; 25 | assert sortedBruteForce(numbers) == true : "SBF: Uh roh. Didn't find 1,9 = 10"; 26 | assert mapSolution(numbers) == true : "Map: Uh roh. Didn't find 1,9 = 10"; 27 | assert arraySolution(numbers) == true : "Array: Uh roh. Didn't find 1,9 = 10"; 28 | System.out.println("PASS - 1+9 = 10"); 29 | 30 | int[] numbers2 = {0,100,342,22,34}; 31 | assert bruteForce(numbers2) == false : "BF: Uh roh. Thinks things sum to 10, but they don't"; 32 | assert sortedBruteForce(numbers2) == false : "SBF: Uh roh. Thinks things sum to 10, but they don't"; 33 | assert mapSolution(numbers2) == false : "Map: Uh roh. Thinks things sum to 10, but they don't"; 34 | assert arraySolution(numbers2) == false : "Array: Uh roh. Thinks things sum to 10, but they don't"; 35 | System.out.println("PASS - Nothing sums to 10"); 36 | 37 | } 38 | 39 | public static boolean bruteForce(int[] a) 40 | { 41 | for(int i = 0; i < a.length; i++) // This loop is O(n) 42 | for(int j = i+1; j < a.length; j++) // This loop is O(n) 43 | if(a[i] + a[j] == 10) // bc loops are nested, solution is O(n^2) 44 | return true; 45 | return false; 46 | 47 | /* tiny optimization: only looks at futher numbers (j=i+1) instead of j starting at 0; 48 | * this also accounts for not getting a false positive bc of something like 49 | * a[i] + a[j] == 10, when both i and j are the same index 50 | */ 51 | 52 | } 53 | 54 | public static boolean sortedBruteForce(int[] a) 55 | { 56 | Arrays.sort(a); // Best case sorting is O(n log n) 57 | int index = 0; 58 | while(a[index] <= 10) // This loop is O(n) bc worst case all nums >= 10 59 | { 60 | for(int j = index+1; j < a.length; j++) // This loop is O(n) 61 | if(a[index] + a[j] == 10) 62 | return true; // This solution is O(n^2) bc we do independent 63 | index++; // big-o analysis in sequence and then choose worst 64 | } 65 | return false; 66 | 67 | /* this solution could claim to optimize the solution because we 'ignore' numbers that 68 | * are greater than 10; however, because we sort the numbers first, this solution is 69 | * actually worse, unless we were guaranteed the numbers were already in order, 70 | * and even then, the gain is negligible 71 | */ 72 | } 73 | 74 | public static boolean mapSolution(int[] a) 75 | { 76 | HashMap under10 = new HashMap(); 77 | //pre-fill map with mappings to 0 to prevent null exceptions later 78 | for(int i = 0; i < 11; i++) 79 | under10.put(i,0); 80 | 81 | // wanted to show a for-each loop in Java, but the following loop could have been written as: 82 | // for(int i = 0; i < a.length; i++) and then sub 'value' for 'a[i]' everywhere it appears. 83 | for(int value : a) // This loop is O(n) 84 | if(under10.containsKey(value)) // This solution is O(n) 85 | under10.put( value, under10.get(value)+1 ); 86 | 87 | // check for all the special combos for a true (SUMS 10) 88 | if(under10.get(5) >= 2) return true; 89 | if(under10.get(10) >= 1 && under10.get(0) >= 1) return true; 90 | if(under10.get(9) >= 1 && under10.get(1) >= 1) return true; 91 | if(under10.get(8) >= 1 && under10.get(2) >= 1) return true; 92 | if(under10.get(7) >= 1 && under10.get(3) >= 1) return true; 93 | if(under10.get(6) >= 1 && under10.get(4) >= 1) return true; 94 | 95 | return false; // We didn't find any of the special combos for a true 96 | 97 | /* In this solution we only traverse the data set once making tallying the 98 | * number of times each unique number appears in the array through aux storage of a (Hash)Map 99 | * key = a specific value in the array 100 | * value = number of times that specific value occured 101 | * Accessing key:value pairings in a HashMap is O(1) so the entire solution rounds out at O(n) 102 | * 103 | * Note that 'put' on a Map replaces the old value with the new value (no duplicate keys) 104 | * 105 | * We could potentially optimize by not adding values<10 to the Map, but that doesn't change 106 | * our latency (time efficiency). It only changes our memory usage, but it's probably 107 | * negligible anyway but maybe worth mentioning or asking what the expected range of values 108 | * within "non-negative" that we should expect 109 | */ 110 | 111 | } 112 | 113 | public static boolean arraySolution(int[] a) 114 | { 115 | int[] countArray = new int[11]; 116 | 117 | for(int value : a) // This loop is O(n) 118 | if(value <= 10) 119 | countArray[value]++; 120 | 121 | // check for all the special combos for a true (SUMS 10) 122 | if(countArray[5] >= 2) return true; 123 | if(countArray[10] >= 1 && countArray[0] >= 1) return true; 124 | if(countArray[9] >= 1 && countArray[1] >= 1) return true; 125 | if(countArray[8] >= 1 && countArray[2] >= 1) return true; 126 | if(countArray[7] >= 1 && countArray[3] >= 1) return true; 127 | if(countArray[6] >= 1 && countArray[4] >= 1) return true; 128 | 129 | return false; // We didn't find any of the special combos for a true 130 | 131 | /* This solution is basically the same as the above solution, but uses a native array 132 | * instead of a Map as auxillary storage 133 | */ 134 | 135 | } 136 | } 137 | ``` 138 | -------------------------------------------------------------------------------- /interview-prep/interview-question-kal.md: -------------------------------------------------------------------------------- 1 | Kal Academy Problem Set 2 | ======================= 3 | 4 | ## Arrays: 5 | 6 | 1. Find the element that appears once in a sorted array where all other elements appear twice one after another. Find that element in 0(logn) complexity. 7 | 8 | > Input: arr\[\] = {1, 1, 3, 3, 4, 5, 5, 7, 7, 8, 8} 9 | > 10 | > Output: 4 11 | 12 | 1. A magic index in an array A\[0…n-1\] is defined to be an index such that A\[i\] = i. Given a sorted array of distinct integers, write a method to find a magic index if one exists, in an array A. FOLLOW UP: What if the values are not distinct? 13 | 14 | 2. Given a sorted array of n integers that has been rotated an unknown number of times, write code to find an element in the array. You may assume that the array was originally sorted in increasing order. 15 | 16 | 3. Given an array that contains numbers from 1 to n-1 and exactly 1 duplicate, find that duplicate. 17 | 18 | 4. Search an element in an array where difference between adjacent elements is 1. 19 | 20 | For example: arr\[\] = {8, 7, 6, 7, 6, 5, 4, 3, 2, 3, 4, 3} 21 | 22 | Search for 3 and Output: Found at index 7 23 | 24 | 5. Given an array of numbers, split the array into two where one array contains the sum of n-1 numbers and the other array with all the n-1 elements. 25 | 26 | ## Stack: 27 | 28 | 1. Find missing parenthesis in a given expression – 2 \* ( 3 + 5(sasdfasdfasd) 29 | 30 | 2. Evaluate an expression given only single digits and only 2 operators \* and +. 31 | 32 | 3. Reverse a stack and put the reversed value back in the same stack. You can use only one other stack and a temp variable. 33 | 34 | ## Strings: 35 | 36 | 1. Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures? 37 | 38 | 2. Given two strings, write a method to decide if one is a permutation of the other? 39 | 40 | 3. Write a method to replace all spaces in a string with ‘%20’. 41 | 42 | 4. Implement a method to perform a basic string compression using the counts of repeated characters. For example, the string aabccccaaa would become a2b1c4a3. If the compressed string would not become smaller than the original string, your method should return the original string. 43 | 44 | 5. Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column are set to 0. 45 | 46 | 6. Given two sequences, print longest common subsequence 47 | 48 | LCS for input Sequences “ABCDGH” and “AEDFHR” is “ADH” of length 3.\ 49 | LCS for input Sequences “AGGTAB” and “GXTXAYB” is “GTAB” of length 4. 50 | 51 | 7. Given two string str1 and str2, find the shortest string that has both str1 and str2 as subsequences. 52 | 53 | Examples: 54 | 55 | Input: str1 = “geek”, str2=”eke” 56 | 57 | Output: “geeke” 58 | 59 | Input: str1 = “AGGTAB”, str2=”GXTXAYB” 60 | 61 | Output: “AGXGTXAYB” 62 | 63 | 8. Remove spaces from a given string in O(n) running time and only one traversal of a string. 64 | 65 | Input: “I love ice cream” 66 | 67 | Output: “Iloveicecream” 68 | 69 | 9. Find all distinct palindromic sub-strings of a given string 70 | 71 | > Input: str = "abaaa" 72 | > 73 | > Output: Below are 5 palindrome sub-strings 74 | > 75 | > a 76 | > 77 | > aa 78 | > 79 | > aaa 80 | > 81 | > aba 82 | > 83 | > b 84 | 85 | 10. Given a string "This is a string" reverse its characters "gnirts a si siht" 86 | 87 | 11. Given a string "This is a string" reverse the characters in every word "siht si a gnirts" 88 | 89 | ## Linked lists: 90 | 91 | 1. Write an algorithm to determine if a linkedlist is a palindrome 92 | 93 | 2. Write an algorithm to determine if a linkedlist is circular. FOLLOW UP: Determine where the circle meets. 94 | 95 | 3. Clone a linked list with a random pointer. 96 | 97 | 4. Write code to remove duplicates from an unsorted linked list. Follow up: How would you solve it if temporary buffer is not allowed? 98 | 99 | 5. Implement an algorithm to find the kth to the last element of a singly linked list 100 | 101 | 6. Implement an algorithm to delete a node a singly linked list, given only access to that node. 102 | 103 | 7. Write code to partition a linkedlist around a value x, such that all nodes less than x come before all nodes great than or equal to x.  104 | 105 | 8. Reverse a linked list – iteratively and recursively 106 | 107 | 9. Given a singly linked list which has data sorted in ascending order, construct a balanced BST. 108 | 109 | ## Trees: 110 | 111 | 1. Given a BST, create a linkedlist of all the nodes at each depth 112 | 113 | 2. Convert a BST into a doubly linkedlist. 114 | 115 | 3. Determine if a binary tree is balanced 116 | 117 | 4. Given a sorted array, create a binary search tree with minimal height 118 | 119 | 5. Implement a function to check if a binary tree is a BST 120 | 121 | 6. Write an algorithm to find the next node (i.e in-order successor) of a given node in a binary search tree. You may assume that each node has a link to its parent 122 | 123 | 7. Design an algorithm and write code to find the first common ancestor of two nodes in a binary tree. Avoid storing additional nodes in a data structure. NOTE: This is not necessarily a BST 124 | 125 | 8. You have 2 very large binary trees: T1 with millions of nodes, and T2 with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of T1. A tree T2 is a subtree of T1 if there exists a node n in T1 such that the subtree of n is identical to T2. That is, if you cut off the tree at node n, the two trees would be identical. 126 | 127 | 9. You are given a binary tree in which each node contains a value. Design an algorithm to print all paths which sum to a given value. Note that a path can start or end anywhere in the tree. 128 | 129 | ## Graph: 130 | 131 | 1. Determine if a path exists from a source node to a destination node 132 | 133 | 2. Print all paths from a given source to a destination 134 | 135 | ## Recursion and Dynamic programming: 136 | 137 | 1. Write an algorithm to print all ways of arranging eight queens on an 8x8 chess board so that none of them share the same row, column or diagonal. In this case, “diagonal” means all diagonals, not just the two that bisect the board. 138 | 139 | ## Bit manipulation: 140 | 141 | 1. Given an array that contains numbers from 1 to n-1 and exactly 1 duplicate, find that duplicate using bit operations. 142 | 143 | 2. Find the number of on(1) bits in a given number. For example, numbr 5 has 2 bits that are 1. Number 7 has 3 bits that are on. 144 | 145 | 3. Subtract two numbers without using arithmetic operators 146 | 147 | 4. How to turn off a particular bit in a number? 148 | 149 | 5. Swap two nibbles in a byte. 150 | 151 | 6. Swap all odd and even bits. 152 | 153 | 7. Binary representation of a given number 154 | 155 | 8. Given an array where every element occurs three times, except one element which occurs only once. Find the element that occurs once. Expected time complexity is O(n) and O(1) extra space.\ 156 | Examples: 157 | 158 | > Input: arr\[\] = {12, 1, 12, 3, 12, 1, 1, 2, 3, 3} 159 | > 160 | > Output: 2 161 | 162 | ## Other: 163 | 164 | 1. Given any integer, print an English phrase that describes the integer (e.g., “One Thousand, Two Hundred Thirty Four”) 165 | 166 | 2. How to determine if a number is a power of 2. 167 | 168 | 3. Find a specific row and a column value in a Pascal’s triangle 169 | -------------------------------------------------------------------------------- /interview-prep/interview-questions-epic-list.md: -------------------------------------------------------------------------------- 1 | Epic List of Interview Questions 2 | ================================ 3 | _modified from: [http://katemats.com/interview-questions/](http://katemats.com/interview-questions/)_ 4 | 5 | Below is a list of software engineer skills or areas that can be tested and evaluated in an interview context. Use the list below to help you get started, and you’ll soon be developing your own favorite questions and competencies for interviews. There are so many creative ways to test and evaluate skills when building your team – so let’s get started! 6 | 7 | Table of Contents 8 | ================= 9 | * [Algorithms - different approaches and performance](#algorithms---different-approaches-and-performance) 10 | * [Problem Solving - like algorithms, only more general](#problem-solving---like-algorithms,-only-more-general) 11 | * [Data Structures - Trees and Graphs](#data-structures---trees-and-graphs) 12 | * [Data Structures - Queues and Stacks](#data-structures---queues-and-stacks) 13 | * [Data Structures - Hash Tables](#data-structures---hash-tables) 14 | * [Abstraction and Design](#abstraction-and-design) 15 | * [Bits and Bytes](#bits-and-bytes) 16 | * [Command Line and Scripting](#command-line-and-scripting) 17 | * [Data Modeling and Data Schemas](#data-modeling-and-data-schemas) 18 | * [SQL Queries - querying for data](#sql-queries---querying-for-data) 19 | * [Networking](#networking) 20 | * [System Design and Thinking](#system-design-and-thinking) 21 | * [APIs](#apis) 22 | * [Web Development](#web-development) 23 | * [Reliability and Operations](#reliability-and-operations) 24 | * [Software Engineering](#software-engineering) 25 | * [Teamwork and Collaboration](#teamwork-and-collaboration) 26 | * [Product Sense and Judgement](#product-sense-and-judgement) 27 | * [Productivity and Ability to Get Things Done](#productivity-and-ability-to-get-things-done) 28 | * [Focus on Quality](#focus-on-quality) 29 | * [Curiosity](#curiosity) 30 | * [Communication](#communication) 31 | * [Passion](#passion) 32 | * [Culture Fit](#culture-fit) 33 | * [More interview questions](#more-interview-questions) 34 | 35 | ## Algorithms - different approaches and performance 36 | 37 | - Write a function that takes two strings as arguments and returns a string containing only the characters found in both strings. Have them write 2 versions – one that is O(n\^2) and one that is O(n). 38 | 39 | - You are given a sorted array and you want to find the number N. How do you do the search as quickly as possible (not just traversing each element)? 40 | 41 | - How would the performance of your algorithm change if there were lots of duplicates in the array? 42 | 43 | - Given two different lists of objects, come up with an efficient solution to find the intersection of the two lists. ([solution](http://www.geeksforgeeks.org/write-a-function-to-get-the-intersection-point-of-two-linked-lists/)) 44 | 45 | - How do you find all the permutations of a string? What is the running time? 46 | 47 | - Now imagine that the string has repeating characters. How could you modify your solution so it would only find unique permutations as efficiently as possible? 48 | 49 | - Given a list of numbers, assume each number represents the amount of time it takes to execute a task. How would you divide the tasks across two different servers to they finished in the same amount of time? 50 | 51 | - Write a program that will find the 10 most popular words (popularity is determined by how often they occur) in a file. How can you do this efficiently in terms of space? In terms of time? // Sometimes it helps to tell them it is a really big file that can’t fit in memory if they get hung up on timing 52 | 53 | - Given an array what is the longest contiguous increasing subsequence of elements? ([solution)](http://allaboutalgorithms.wordpress.com/2011/10/21/maximum-value-contiguous-subsequence-maximum-contiguous-sum/) 54 | 55 | - Create an algorithm that will output the results of rolling a die (1-6) using a function that simulates a coin toss (1 or 2). All 6 outcomes should be equally likely. ([solution](http://users.dickinson.edu/~braught/courses/cs131s99/Lessons/16-Counters.html)) 56 | 57 | - Given an array of integers write a program that will determine if any two numbers add up to a specified number N. Do this without using hash tables. ([solution](http://stackoverflow.com/questions/2666654/how-to-write-an-algorithm-to-check-if-the-sum-of-any-two-numbers-in-an-array-lis), although some use hash tables) 58 | 59 | ## Problem Solving - like algorithms, only more general 60 | 61 | - Given a dollar value come up with all the different ways to make change given the standard coin denominations ([solution](http://stackoverflow.com/questions/1106929/find-all-combinations-of-coins-when-given-some-dollar-value)). 62 | 63 | - Count the 2’s between 0 and N. And every 2 digit counts as a 2, so if N was 7 the answer would be 1 (just the number 2), whereas if n was 23 there would be 7 2’s {2, 12, 20, 21, 22 (this counts for 2), 23}. // This is actually pretty challenging and one of my favorite questions to ask candidates that are doing really well in with lots of other questions. Getting the brute force answer is easy, coming up with an elegant solution takes a little more effort. 64 | 65 | - How many degrees are there in the angle between the hour and minute hands of a clock when the time 4:15? // You can also use the current time if there is a clock in the room. You aren’t looking for a wild guess but for someone who can rationalize out the answer. For candidates rusty on geometry I will give them the number of degrees in a circle via hints 66 | 67 | Here are some [other problem solving questions too](http://www.recruiter.com/i/the-best-interview-questions-ever/), if you need additional examples. 68 | 69 | ## Data Structures - Trees and Graphs 70 | 71 | - How do you find the 7th element in a binary search tree? How do you generalize the function to find the Nth element? ([solution](http://stackoverflow.com/questions/2612362/nth-largest-element-in-a-binary-search-tree)) 72 | 73 | - Given two binary trees write a function that will compare the two and see if they are equal – both in terms of data and structure. ([solution](http://stackoverflow.com/questions/9597188/the-most-efficient-way-to-test-two-binary-trees-for-equality)) // You can also do just data or just structure to mix it up. Just make sure you know how to explain the differences. 74 | 75 | - Write a function to determine if a graph contains a cycle. ([solution](http://www.geeksforgeeks.org/detect-cycle-in-a-graph/)) 76 | 77 | ## Data Structures - Queues and Stacks 78 | 79 | - Design and implement a stack. Implement the different methods: push, pop, retrieve the minimum element in constant time. ([solution](http://leetcode.com/2010/11/stack-that-supports-push-pop-and-getmin.html)) 80 | 81 | - Design a queue using stacks as the underlying data structure ([solution](http://www.impactinterview.com/2009/10/140-google-interview-questions/)). Implement a stack using queues as the underlying data structure ([solution](http://stackoverflow.com/questions/688276/implement-stack-using-two-queues)). 82 | 83 | ## Data Structures - Hash Tables 84 | 85 | - How do hash tables work? What are some examples of real life hash tables? When is a hash table a poor data choice? 86 | 87 | - What are different ways of managing collisions? 88 | 89 | - Implement a hash table. 90 | 91 | - Find the first non-repeated character in a string. 92 | 93 | ## Abstraction and Design 94 | 95 | - Have you ever seen OO go bad? What happened? What elements of OO design are most prone to abuse and misuse? What are some ways to prevent these mishaps? 96 | 97 | - Implement a game of tic-tac-toe. How do you represent the game board? What interfaces do you expose? 98 | 99 | - You are tasked with designing software that runs and controls elevators. What interfaces and class objects would you use? What configuration options would you need for the software to work in skyscrapers, buildings with only one elevator, and buildings with banks of elevators? How would these use cases change the objects and interfaces in your design? 100 | 101 | - Imagine you were tasked with designing a text editor (or instant messaging program). What are the primary functions? What are the various interfaces, classes, etc. that you would need to provide those functions? // and feel free to replace text editor with any common small program of your choosing (mobile apps make great examples) 102 | 103 | ## Bits and Bytes 104 | 105 | - How much space would you need to store 1 billion phone numbers? 106 | 107 | - Convert a binary (or hex, or any other base of your choosing) string to an integer. Convert an integer to binary (or hex, or any other base of your choosing). 108 | 109 | - If you had a product catalog of 1 million items how much space would you need to store all of them? Assume each item has a title, a description and price. // feel free to set limits on the fields or your choosing, or ask the candidate to pick something reasonable. 110 | 111 | 112 | ## Command Line and Scripting 113 | 114 | - Write a regular expression which matches a email address // You can use url, phone number, etc. instead of email address 115 | 116 | - How would you find all the \*.plist files in a directory via the command line? 117 | 118 | - What is a shell? What kind of shell do you use? Have you customized it all? If yes, what are some of your customizations? 119 | 120 | - How do you view all the processes running on a Linux system? When might you want to do this? 121 | 122 | 123 | ## Data Modeling and Data Schemas 124 | 125 | - Design a data schema for \[insert example here\]. // I like to use one of the products or features at my company, but you could also use familiar scenarios like: course catalog for students, a rental car database, a flight database for an airline, inventory for an ecommerce site, etc. 126 | 127 | - Have you ever had to design a data model from scratch? What project was it? Was there ever any issues? What do you think you got really right, and what could have been improved? 128 | 129 | ## SQL Queries - querying for data 130 | 131 | - What is a primary key? 132 | 133 | - You know that data is in a particular table but you don’t know what the schema is for that table. How could you figure it out? 134 | 135 | - What are some different kinds of joins? How do they work? Can you give examples? 136 | 137 | - What is the difference between GROUP BY and ORDER BY? 138 | 139 | - Write a query to delete duplicate rows from a table. 140 | 141 | - For more SQL questions, [check out Jitbit’s guide here](http://www.jitbit.com/news/181-jitbits-sql-interview-questions/). 142 | 143 | 144 | ## Networking 145 | 146 | - What are some common networking protocols and what makes them special? Any of the following will work: TCP, UDP, HTTP, DNS, but there are way more. // In the event the candidate starts to explain one you are less familiar with take notes and ask questions – you can verify their knowledge later and test their communication now. 147 | 148 | - A customer complains your website is slow. How do you troubleshoot the issue? 149 | 150 | - Describe what happens when I type “google.com” into a browser and hit return. Be as detailed as possible. 151 | 152 | 153 | ## System Design and Thinking 154 | 155 | - What are some alternate ways to store data besides using a relational database? Do you have any experience with other data stores? What was the use case? Why might you consider an alternate solution (to an relational DB) and what would be the downsides of doing so? 156 | 157 | - What is the difference between stateless and stateful systems? How does this impact scaling? 158 | 159 | - What is a cache? In your past projects, what types of caches were present? How would you decide if you should buy servers with more memory or disk space? How would you develop a cost model to help you make the decision? // This question is probably best for someone with some experience managing or having exposure to servers. You can still answer it without that knowledge of course, but there may be better questions. 160 | 161 | ## APIs 162 | 163 | - Why are interfaces important to software and systems? What are some examples of "interfaces" you have built or used in a previous project? 164 | 165 | - Describe a situation where you had to use a RESTful web service? What were the languages and technologies that you used? Did you learn anything from the experience? 166 | 167 | - What are some qualities of a well designed API? How about a poorly designed one? // Feel free to replace the example with anything that involves data, hopefully something that relates to your product and business. 168 | 169 | - How do you keep APIs secure? What are some considerations with API security? 170 | 171 | 172 | ## Web Development 173 | 174 | - **JavaScript** 175 | 176 | - What JavaScript libraries (or frameworks if you would prefer) have you used? 177 | 178 | - Explain AJAX in as much detail as possible. How does it work? What have you used it for in the past? 179 | 180 | - You want to get a query string parameter from the browser’s URL, how would you do it? 181 | 182 | - What is the difference between document load and document ready events? 183 | 184 | - What are ways to write object oriented JavaScript? For example, explain how inheritance works. 185 | 186 | - **HTML** 187 | 188 | - What are some of the building blocks of HTML5? 189 | 190 | - What is the difference between cookies, sessionStorage and localStorage? 191 | 192 | - **CSS** 193 | 194 | - How do you organize CSS files? What are the pros and cons of this approach? Have you ever tried other ways? 195 | 196 | - How do you avoid duplicating colors or fonts in CSS, when those colors or fonts are applied to multiple elements? What are the pros and cons of that approach? 197 | 198 | - What is the CSS box model? (A: width/padding/border/margin) 199 | 200 | - What are some clearing techniques and when is it appropriate to use them? 201 | 202 | - What is the difference between “visibility:hidden” and “display:none”? What are the pros and cons of using “display:none”? 203 | 204 | - How does the browser determine where to place positioned elements? 205 | 206 | - **Web Browsers** 207 | 208 | - What is responsive design? What is the difference between fixed and fluid layouts? What are some of the pros and cons with these designs? 209 | 210 | - How do you do browser compatibility testing? 211 | 212 | - What are some ways to prevent web browser caching? 213 | 214 | - What is your favorite browser? What sort of tools do you use to debug websites? 215 | 216 | - What are some considerations in selecting font sizes? // This question is focused on accessibility 217 | 218 | - How does the DOM work? Explain in as much detail as possible. 219 | 220 | - What do you think of “hacks”? When should they be used in your code and when should they be avoided? 221 | 222 | - What is MVC and why is it useful? When would MVC not be an appropriate design pattern choice? 223 | 224 | - What are the advantages of client side rendering vs. server side rendering? If you were building our site which would you use and why? 225 | 226 | - What does minification do? 227 | 228 | - What are some ways to make websites faster? Name as many different techniques as you can. 229 | 230 | - How do you test the performance of your code and/or web pages? 231 | 232 | - What are some common security issues with web applications and how do you avoid them? 233 | 234 | - What is the difference between Canvas and SVG? Do you have experience with either? 235 | 236 | ## Reliability and Operations 237 | 238 | - Have you ever had someone let you down at work? What happened? How did you handle it? What did you learn and did it change the way you did things? 239 | 240 | - Can you describe a stressful situation from a previous role. What you did to create a positive outcome? How do you manage stress in your daily work? 241 | 242 | - Have you ever had a bug in your code that showed up in production? What happened? What did you learn from the experience? 243 | 244 | - Tell me about a time when you had to go above and beyond the call of duty to complete your work. 245 | 246 | - Tell me about a situation when you aren’t able to complete you work. What happened? What did you learn from the situation and experience? 247 | 248 | - What is the purpose of retrospectives, and why are they useful? What are the attributes that make a great retrospective? 249 | 250 | ## Software Engineering 251 | 252 | - How would you describe the software lifecycle at your last position? What did you like about it? What did you wish you could change? 253 | 254 | - What is an example of a [sandbox](http://en.wikipedia.org/wiki/Sandbox_%28computer_security%29)? Have you ever used one? What is the purpose of one and what are some potential alternatives? 255 | 256 | - What does refactoring mean to you? Why is it important and when have you done it? (Some candidates can even talk about different refactorings and design patterns here, but mostly I am looking for someone who wants to improve the code they write – as very few people ever get it all right the first time) 257 | 258 | - Given the following variables: time, budget, customer happiness and best practices which are most important in a project? Give them an order and explain why. 259 | 260 | - What is the advantages of best practices like continuous integration, automated testing, and code reviews? What are the disadvantages of these practices? (Feel free to insert your own best practices too, these are just examples.) 261 | 262 | - Are you familiar with the concept of [convention over configuration](http://en.wikipedia.org/wiki/Convention_over_configuration)? What is an example? 263 | 264 | - How do you design, develop and debug applications? What tools do you like to use best? Have you tried others before? What were the reasons you use the ones you do? // There is really no right answer here, it is mostly just about learning how they do their work, and how it fits into past projects. Good answers usually involve thoughtful responses on trade-offs, technology, and experience. 265 | 266 | ## Teamwork and Collaboration 267 | 268 | - Give examples of project that were completed as a team. Were there any that went better than others? Why? What was different? 269 | 270 | - What is the best way to collaborate on a coding project? 271 | 272 | - Have you ever had to deal with features that involved multiple people working in the same areas? How did it go? Was there anything that could have been done to improve it? 273 | 274 | - Do you do your best work alone or in a group? Does the type of work matter? 275 | 276 | - What does it mean to be a good teammate? Have you ever had any bad teammates? If so, did you tell them and give the feedback? 277 | 278 | - Have you ever had to work with someone else that didn’t pull their weight on a project? How did you handle it? Did things ever improve? If you had to do it all over again would you change anything? 279 | 280 | - We are in the middle of a development cycle (or sprint if you use agile) and there is a major change in the functionality of a feature you have been working on. How do you respond? What questions do you ask? 281 | 282 | ## Product Sense and Judgement 283 | 284 | - What is a really well designed website that you use? What makes it great? // This is also a great question to ask if you have a web browser and can pull it up and have the candidate walk you through it 285 | 286 | - Describe the structure and contents of a design document. What do you consider the minimum amount of information for development to start building something? Give an example of when you didn’t have enough information, or when you had too much/unnecessary information. 287 | 288 | - (For more questions on this note, there is an [amazing post here on hiring a product manager](https://www.kennethnorton.com/essays/productmanager.html) but a lot of the questions could easily be adapted here as well) 289 | 290 | ## Productivity and Ability to Get Things Done 291 | 292 | - Tell me about a time you did something that you were really proud of but no one else knew about. // Ideally they should answer with some sort of cleanup work, like refactoring, or fixing other issues, or maybe even something as simple as cleaning up the kitchen. You want a sign that they care about work that is more than just the tasks they are assigned. 293 | 294 | - How do you manage your tasks and stay organized? 295 | 296 | - Tell me about a time when you were the most productive. What made that time special? Did you change anything about your day to day work to take advantage of those same attributes? 297 | 298 | - You have been assigned to a project in a new technology you haven’t worked with before. How do you get started? Have you ever done this before? How did it go? 299 | 300 | 301 | ## Focus on Quality 302 | 303 | - When do you consider a product to be finished? // My favorite response is ‘it’s never finished’ but anything about some level of testing or verification is generally acceptable. 304 | 305 | - When do you know your code is ready for prime time (shipping to production)? 306 | 307 | - Explain a feature or product. How would you test this feature (or product)? You can also ask how to test a specific function after a coding problem. 308 | 309 | - You have just been put in charge of a big legacy piece of software with some serious maintenance issues. What do you do first? // This question works best if you have a product or example with some issues in mind – otherwise it can be a pretty abstract question. 310 | 311 | - Have you ever done TDD? Do you like it? Why or why not? 312 | 313 | - There are all different types of tests – unit tests, smoke tests, acceptance tests, integration tests, etc. What sort of tests have you written? What’s the difference between \[insert test here\] and \[insert different test here\]? 314 | 315 | ## Curiosity 316 | 317 | - What was the last new technology or tool you learned? Where did you learn about it? Have you used it since? 318 | 319 | - What is the last programming (or technical) book you read? 320 | 321 | - When was the last time you got something wrong? How did you know? What did you learn from it? 322 | 323 | ## Communication 324 | 325 | - Teach me about something for the next 10 minutes. // You are looking for them to select a topic they know (I generally don’t care if they are technical or not) and how well they communicate and break things down. 326 | 327 | - How did you communicate progress in your previous role? Did that process always work? What could have been done differently to keep everyone on the same page? 328 | 329 | - Tell me about a time when you had a miscommunication at work. What happened? If you could do it all over again would you alter your actions? Why or why not? 330 | 331 | - How would you explain the Internet to a child? 332 | 333 | - Have you ever disagreed with your boss or manager? What did you do? If you haven’t had this happen, imagine that it did, how would you handle this situation? 334 | 335 | - Explain the concept of cloud computing to my older (not-very-technical) mother. // I actually had to do this in real life and it was harder than I expected. Another example is explain a database to someone’s grandparents. 336 | 337 | - Give me an example of a time when you were able to communicate and work with another person even when they may not have personally liked you (or vice versa). 338 | 339 | ## Passion 340 | 341 | - Do you have any personal projects? Tell me about them. // This is probably one of my favorite and most important questions. When I hire I like to hire candidates who are very passionate about what they do, and so programming isn’t something they just do at their job. They are actually passionate about it and pursue their own projects outside of work. 342 | 343 | - If money weren’t an issue and you had to work on a project for 3 months, what would you create? 344 | 345 | - What are 3 big contributors to your success? 346 | 347 | - Give me an example of a goal you set for yourself and how you achieved it. 348 | 349 | ## Culture Fit 350 | 351 | - Tell me about 3 times you have failed. // Almost anyone can come up with 1 or 2, but it can be hard to think of 3. Be sure to wait and be quiet while the candidate thinks and ponders the answer – I often feel like the most insightful answers come towards the end of this question. 352 | 353 | - What do you want to do in 5 years? How would this job fit into your plan and help you toward your goals? 354 | 355 | - Why do you want to work at \[company name\]? Have you used our products? Is there a particular area or feature that got you excited? 356 | 357 | - Give an example of when you completed a task without being asked. Can you give me another example? Another? 358 | 359 | - Tell me about a time you improved a tool, task, or project you were working on. What was the circumstances? Why did you do it? Do you have any other examples? 360 | 361 | ## More interview questions 362 | 363 | Here are a few lists of questions to check out. You can also just try searching for specific questions or skills that you are looking for – there is no shortage of questions to ask. 364 | 365 | - 366 | 367 | - 368 | 369 | - 370 | 371 | - [http://www.joelonsoftware.com/articles/fog0000000073.html](http://www.joelonsoftware.com/articles/fog0000000073.htmlhttp://www.impactinterview.com/2009/10/140-google-interview-questions/) 372 | 373 | - [http://www.impactinterview.com/2009/10/140-google-interview-questions/](http://www.joelonsoftware.com/articles/fog0000000073.htmlhttp://www.impactinterview.com/2009/10/140-google-interview-questions/) 374 | 375 | - 376 | 377 | - Web Development focused: 378 | --------------------------------------------------------------------------------