├── README.md ├── Syllabus.md ├── section1 ├── List_Searching.md ├── List_Sorting.md ├── Math_Problems.md ├── Recursion.md └── String_Parsing.md ├── section3 └── Linked_Lists.md └── test.py /README.md: -------------------------------------------------------------------------------- 1 | #Interview Prep# 2 | 3 | These course materials are designed to prepare you for a technical whiteboarding interview at a tech company in San Francisco. The main point of these interviews is to see what your problem-solving skills are like, to see how you think through things, how you behave under pressure, and to test your memory of syntax of a programming language. 4 | 5 | Unfortunately, the skills you must aquire in order to pass a whiteboarding interview are dissimilar to those that you learned when you learned programming. You will still need this programming knowledge, and you will need the problem-solving skills you've picked up while learning to program, but because you're not going to be in an idealized programming environment, you must be able to program in unfamiliar environments. 6 | 7 | If you are a senior developer, you can probably make it through this curriculum in two weeks. 8 | 9 | A mid-level developer will range from 3-6 weeks. 10 | 11 | Junior developers may take anywhere from 6 to 12 weeks to finish this course. 12 | 13 | ##Structure## 14 | * Syllabus 15 | * Section One - Basic Functions 16 | * Section Two - Data Structures 17 | * Section Three - Linked Lists, Trees, Graphs 18 | * Section Four - Object Oriented Programming 19 | * Section Five - Problem Solving for Longer Problems 20 | * Section Six - Brain Teasers 21 | * Section Seven - Pairing 22 | * Section Eight - Technology 23 | * Section Nine - Databases 24 | * Section Ten - Software Engineering 25 | 26 | 27 | ## Running This Curriculum 28 | This course should be started at least four weeks prior to the end of the immersive if it is used for an immersive engineering program. You should cover at least 1 unit per week. It depends on prior, but recent, programming experience. It was designed for use by immersives, but should you wish to run it as a study group you should meet up at least 4 times a week, for 2.5 hours. 29 | 30 | Spend at least an hour each day completing these challenges on paper. Use pencil. 31 | Spend at least an hour each day practicing doing these challenges on a whiteboard, in front of at least one other person. 32 | Spend at least half an hour reading other people's solutions to these problems, and watching other people solve them. 33 | 34 | 35 | 36 | Basic functions 37 | ================ 38 | 39 | ##Exercises## 40 | 1. [String Parsing](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/String_Parsing.md) 41 | 1. [Reverse](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/String_Parsing.md#reverse) 42 | 2. [Palindromes](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/String_Parsing.md#palindromes) 43 | 3. [Substr](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/String_Parsing.md#substr) 44 | 4. [Split](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/String_Parsing.md#split) 45 | 2. [List Searching](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/List_Searching.md) 46 | 1. [Missing Number](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/List_Searching.md#missing-number) 47 | 2. [Highest Int](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/List_Searching.md#highest-int) 48 | 3. [Highly Divisible](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/List_Searching.md#highly-divisible) 49 | 4. [Binary Search](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/List_Searching.md#binary-search) 50 | 3. [Recursion](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/Recursion.md) 51 | 1. [Fibonacci Recursion](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/Recursion.md#fibonacci-recursion) 52 | 2. Recursive List Manipulations 53 | 1. [Length](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/Recursion.md#recursive-list-length) 54 | 2. [Reverse](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/Recursion.md#recursive-list-reverse) 55 | 3. [Find](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/Recursion.md#recursive-list-find) 56 | 57 | ##Concepts## 58 | 1. Big O Notation 59 | 2. Whiteboarding Strategies 60 | 1. Start at the top 61 | 2. Write down the problem 62 | 3. Problem Solving Out Loud - Keep talking 63 | 4. Don't try to come up with the right answer first, just one that works 64 | 5. How to ask clarifying questions 65 | 3. Basic Logic 66 | 4. Problem Structure 67 | 5. Recursion 68 | 69 | ##Unit Design## 70 | Students are given a number of minutes (decreasing each day) to complete several problems on paper in the lecture hall. After that number of minutes elapses, students who have completed their questions are asked to demonstrate it on the board. Lecturers go over the different strategies used, and critique the efficiency and effectiveness of the solution. TAs are needed to check the validity of student's work, as it is on paper. Lecturers should strive to talk over the skills covered by each exercise, because some solutions to come problems may miss key concepts. 71 | 72 | Exercises are meant to get students comfortable with solving problems without an IDE present, with making mistakes, and with timed problem solving. Social pressure should be applied, but is not the main focus of this unit. 73 | 74 | ##Suggested Reading## 75 | ###Videos### 76 | [Programming Interviews w/Noah Kindler](http://vimeo.com/79718197) 77 | ###Books### 78 | [Programming Interviews Exposed](http://www.amazon.com/Programming-Interviews-Exposed-Secrets-Landing/dp/1118261364/) 79 | [Cracking The Coding Interview](http://www.amazon.com/Cracking-Coding-Interview-Programming-Questions/dp/098478280X) 80 | [Big O Notation Explained](https://www.youtube.com/watch?v=KSNx22U4uWE) 81 | 82 | ###Other Resources### 83 | [140 Google Interview Questions](http://www.impactinterview.com/2009/10/140-google-interview-questions/) 84 | [Math-heavy Big O Notation](http://www.leda-tutorial.org/en/official/ch02s02s03.html) 85 | [Big-O Cheat Sheet](http://bigocheatsheet.com/) 86 | 87 | ###Bonus Material### 88 | 1. [List Sorting](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/List_Sorting.md) 89 | 1. Sorts 90 | 1. [bubble](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/List_Sorting.md#bubble-sort) 91 | 2. [merge](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/List_Sorting.md#merge-sort) 92 | 3. [quick](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/List_Sorting.md#quicksort) 93 | 2. Partial Sorts 94 | 1. [find top ten](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/List_Sorting.md#top-10) 95 | 2. [pivot](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section1/List_Sorting.md#pivot) 96 | 2. Using Math To Solve Problems 97 | 1. [Prime Numbers](https://github.com/lizTheDeveloper/Interview-Prep/blob/master/section1/Math_Problems.md#primes) 98 | 1. return the nth prime 99 | 2. isPrime 100 | 2. Factorials 101 | 1. [n Factorial](https://github.com/lizTheDeveloper/Interview-Prep/blob/master/section1/Math_Problems.md#factorial) 102 | 2. [List Prime Factors](https://github.com/lizTheDeveloper/Interview-Prep/blob/master/section1/Math_Problems.md#list-factors) 103 | 3. Greatest Common Factor 104 | 3. [Fibonacci](https://github.com/lizTheDeveloper/Interview-Prep/blob/master/section1/Math_Problems.md#exercise-3) 105 | 1. Fibonacci with recursion 106 | 2. Fibonacci iteratively 107 | 3. Fibonacci with caching 108 | 109 | 110 | Data Structures 111 | =========================== 112 | ##Exercises## 113 | 1. The Answer Is Dictionaries 114 | 1. find if there are pairs 115 | 2. Are all the letters from string a in string b? 116 | 3. Roman Numerals 117 | 2. How To Write Your Own Hash Map 118 | 3. Stacks 119 | 4. Queues 120 | 5. Heaps 121 | 6. Keeping Your Data Organized 122 | 1. Variables 123 | 1. Keeping Pointers 124 | 2. Keeping Counters 125 | 2. Lists 126 | 1. Using Lists as Stacks 127 | 2. Using Lists as Queues 128 | 3. Dictionaries 129 | 1. When to use a dictionary 130 | 2. Hash Map Properties 131 | 4. Sets 132 | 1. Using Sets instead of Hash Maps 133 | 2. Using Sets and Length 134 | 135 | ##Concepts## 136 | * Data structure as it relates to efficiency 137 | * Space 138 | * Time 139 | * Objects 140 | 141 | ##Unit Design## 142 | These exercises are longer and should be done in breakout sessions on various whiteboards. Emphasis is more on problem solving than speed, and making conceptual leaps out loud. This unit is designed to introduce social pressure while making conceptual leaps. Experimenting with group size should be done to find the right mix of pressure and even coverage of problems to students. Problems should be done in sets of increasing difficulty, so weaker students should attempt the early problems, and stronger students should attempt the later problems. 143 | 144 | Weaker students during this time will get the help they need with problem solving in general, and do not need the additional efficiency and complexity training that stronger students need, as they will typically end up in interviews where completing the problem presented in the interview is sufficient. 145 | 146 | Stronger students should focus their efforts on understanding the efficiency and complexity of problems that "build" on the concepts that the weaker students solve, as they will be more apt to face tougher interview questions with more room to express efficiency and understanding. 147 | 148 | ##Suggested Reading## 149 | [Stacks](http://interactivepython.org/runestone/static/pythonds/BasicDS/stacks.html) 150 | [Queues](http://interactivepython.org/runestone/static/pythonds/BasicDS/queues.html) 151 | ###Books### 152 | 153 | ###Relevant Exercises### 154 | 155 | ###Other Resources### 156 | 157 | Linked Lists, Trees, Graphs 158 | ==================== 159 | 1. Linked Lists 160 | 1. [Find Tail](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section3/Linked_Lists.md) 161 | 2. [Find Loops](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section3/Linked_Lists.md) 162 | 3. [Find Kth Element](https://github.com/lizthedeveloper/Interview-Prep/blob/master/section3/Linked_Lists.md) 163 | 2. Trees 164 | 1. DFS 165 | 2. BFS 166 | 3. Binary Search 167 | a. Largest element 168 | b. 5th largest 169 | Efficiency 170 | 4. Red-Black Trees 171 | 5. Equality 172 | a. total value of data 173 | b. actual equality 174 | 3. Graphs (optional) 175 | 176 | ##Concepts## 177 | * Linked Lists 178 | * Nodes 179 | *Trees 180 | * Nodes 181 | * Recursion 182 | * Graphs 183 | * Objects 184 | * Object References 185 | * Diagramming 186 | 187 | ##Unit Design## 188 | Problems here are designed to reintroduce students to Object Oriented Programming, as they likely have not written much in the way of classes outside of an ORM. It will remind them that Objects are a data structure unto themselves. It it also meant to introduce students to more complex algorithms, and graph problems. Many students may have tackled graph-style problems in their projects, but have likely used a library that handled data structures for them, so will need to be reintroduced to these concepts. 189 | 190 | Weaker students will be mostly focused on understanding the difference between an object and a reference, whereas stronger students will be more focused on complex structures such as red-black trees and graphs. 191 | 192 | ##Suggested Reading## 193 | ###Videos### 194 | [Object Oriented Programming Lecture](http://vimeo.com/76652734) 195 | ###Books### 196 | 197 | ###Relevant Exercises### 198 | 199 | ###Other Resources### 200 | [Linked Lists](http://interactivepython.org/courselib/static/pythonds/BasicDS/linkedlists.html) 201 | [Implementing a Linked List](http://interactivepython.org/courselib/static/pythonds/BasicDS/linkedlists.html#implementing-an-unordered-list-linked-lists) 202 | [Trees](http://interactivepython.org/courselib/static/pythonds/Trees/trees.html) 203 | [Trees as a data structure (Wikipedia)](http://en.wikipedia.org/wiki/Tree_(data_structure)) 204 | [Graphs](http://interactivepython.org/courselib/static/pythonds/Graphs/graphintro.html) 205 | 206 | OOP Concepts 207 | ============ 208 | 1. Building 209 | 1. Card games 210 | 2. Chess 211 | 3. RoShamBo 212 | 4. Tic Tac Toe 213 | 2. Vocab 214 | 1. Encapsulation 215 | 2. Polymorphism 216 | 3. Inheritance 217 | 4. Composition 218 | 3. Patterns 219 | 1. Inheritence 220 | 2. Composite 221 | 3. Chain of Responsibility 222 | 4. Observer 223 | 224 | ##Concepts## 225 | * Classes 226 | * Object Instantiation 227 | * Syntax 228 | * Program Structure 229 | 230 | ##Unit Design## 231 | Students by this time should be more comfortable with creating classes and objects, and so should branch out into different patterns of design, and know their names. Though this unit is not extensive enough to have students fully understand every type of OOP pattern, they should be familiar with Inheritence, Composite, potentially Chain of Responsibility and potentially Observer, as both are becoming more widely used in various web frameworks. 232 | 233 | Weaker students may not be able to complete the latter portions of this unit, but should understand how to use classes. 234 | ##Suggested Reading## 235 | ###Videos### 236 | [Object Oriented Programming Lecture](http://vimeo.com/76652734) 237 | ###Books### 238 | 239 | ###Relevant Exercises### 240 | 241 | ###Other Resources### 242 | [Design Patterns by Type (Wikipedia)](http://en.wikipedia.org/wiki/Design_Patterns#Patterns_by_Type) 243 | 244 | Longer Problems 245 | =============== 246 | 1. Multiple Functions 247 | 1. Given a set of coin denominators, find the minimum number of coins to give a certain amount of change. 248 | 2. Given an array, i) find the longest continuous increasing subsequence. ii) find the longest increasing subsequence. 249 | 3.Predictive Text / Spell Checker 250 | 4. Shunting yard (roman numerals, prefix notation) 251 | 252 | ##Concepts## 253 | * Stubbing Functions 254 | * Problem Solving in Multiple Steps 255 | * Syntax "looseness" for whiteboarding problems 256 | 257 | ##Unit Design## 258 | By now students typically have difficulty envisioning problems that require more than one function to solve, or don't involve recursion or objects. This section is intended to remind students that composing functions and their use took up the bulk of their work to date, and that frequently whiteboarding problems are easier to solve if they break them down into smaller functions. 259 | This unit is generally intended to help their whiteboarding strategy and so the placement of this unit is more about where the student is and less about conceptual similarity to other units. 260 | 261 | The difficulty of this unit should restore the confidence of students struggling with OOP concepts as well, and should help students who have difficulty breaking down large problems by having them start by deciding which functions they will need to solve the problem. 262 | 263 | This module should also introduce syntax looseness - shortening of variable names, not bothering to write boilerplate code, and should make students comfortable with working through a large problem on a whiteboard by intentionally choosing what to complete, and what to demonstrate mastery of verbally. 264 | ##Suggested Reading## 265 | ###Videos### 266 | 267 | ###Books### 268 | 269 | ###Relevant Exercises### 270 | 271 | ###Other Resources### 272 | 273 | 274 | Brain Teasers 275 | ============= 276 | 1. Estimation 277 | 1. How many jelly beans in a jar? in a house? in a 747? 278 | 2. Problems that are Programming 279 | 1. 100 story tower, you have two boxes, find the lowest floor you can drop boxes from 280 | 2. 100 bottles of wine, one is poisoned - you have an hour, poison takes an hour, fewest number of servants 281 | 3. Other Problems 282 | 1. box with water and a boat, throw something off boat - water level rise or fall or stay the same? 283 | 2. fox, sheep, wheat 284 | 3. lightbulb in a house - feel the lightbulb 285 | 4. 3000 apples - truck driver eats an apple every meter, go 1000 meters, how many apples can make it? 286 | 5. the mouse - where is the randomly moving mouse? 287 | 4. Problems in the Real World 288 | 289 | ##Unit Design## 290 | Brain Teasers as a module is designed to familiarize students with the process of solving something that does not involve using code. Problems around estimation, order of magnitude, and problems that involve computer science concepts without computers. Teaching students to spot computer science problems in the real world will help them come across better in interviews, and teach them not to get stuck by problems whose solution is not obvious. The idea of real-world problems being solved mathematically will be best absorbed by students with a strong math background, but all students should be able to benefit from this unit. 291 | 292 | ##Suggested Reading## 293 | ###Videos### 294 | [Some Video](http://vimeo.com/70764383) 295 | ###Books### 296 | 297 | ###Relevant Exercises### 298 | 299 | ###Other Resources### 300 | 301 | Kahn Academy 302 | Basic Algebra 303 | Linear Algebra 304 | Applied Math 305 | Vi Hart Videos 306 | http://www.youtube.com/watch?v=e4MSN6IImpI&list=SPF7CBA45AEBAD18B8 307 | http://www.youtube.com/watch?v=a-e8fzqv3CE&list=PLC20F52B96F3E8206 308 | 309 | 310 | Pairing - review 311 | ================ 312 | 1. Pairing on code 313 | 2. Pairing on TDD 314 | 3. Pairing on a codebase 315 | 316 | ##Unit Design## 317 | This is less a module and more a suggestion to our students to pair with their mentors, and what they should do on their own to study. 318 | 319 | ##Suggested Reading## 320 | ###Videos### 321 | ###Books### 322 | ###Relevant Exercises### 323 | ###Other Resources### 324 | 325 | 326 | Technology 327 | ========== 328 | 1. How does the internet work? 329 | 1. DNS, Routers, Hubs, Request/Response, HTTP / TCP/IP (deep as you can get) 330 | 2. What is the request / response lifecycle / what happens when you type google.com into a browser? 331 | 3. GET v POST 332 | 1. Explain the difference 333 | 2. Know the syntax of an HTTP Request 334 | 3. Understand what a post body looks like / URL Encoding 335 | 336 | ##Suggested Reading## 337 | ###Videos### 338 | [Some Video](http://vimeo.com/89469263) 339 | ###Books### 340 | ###Relevant Exercises### 341 | ###Other Resources### 342 | 343 | Databases 344 | ========== 345 | 1. Schema Design 346 | 1. Create schema for a book-trading website 347 | 2. Create a schema for a kingdom that exports many kinds of fruit and vegetables 348 | 1a. Add tarrifs 349 | 1b. Add suppliers 350 | 1c. Add imports 351 | 1d. Write some queries against these tables 352 | 3. Create a schema for a ticket sales website 353 | 2. Write SQL Queries 354 | 1. Get current LTV (lifetime value) of a user by totaling their orders 355 | 2. Get LTV of all users by state 356 | 3. Get LTV of all users that have come in through a certain refferal campaign 357 | 3. Indexes & Constraints 358 | 359 | ##Suggested Reading## 360 | ###Videos### 361 | ###Books### 362 | ###Relevant Exercises### 363 | ###Other Resources### 364 | 365 | Software Engineering 366 | ==================== 367 | 1. Explain MVP 368 | 2. Explain Functional Programming 369 | 3. Explain OOP 370 | 4. Explain Dynamic Programming 371 | 372 | ##Suggested Reading## 373 | ###Videos### 374 | ###Books### 375 | ###Relevant Exercises### 376 | ###Other Resources### 377 | 378 | 379 | 380 | 381 | Resources: 382 | http://www.impactinterview.com/2009/10/140-google-interview-questions/ 383 | http://en.wikipedia.org/wiki/Design_Patterns 384 | http://en.wikipedia.org/wiki/Tree_(data_structure) 385 | https://github.com/flatiron-school/prework.flatironschool.com 386 | https://github.com/nyghtowl/Interview_Problems 387 | https://github.com/mmihaljevic/algortihms_challenges 388 | Topcoder.com 389 | -------------------------------------------------------------------------------- /Syllabus.md: -------------------------------------------------------------------------------- 1 | Syllabus 2 | ========= 3 | 4 | ##Section 1## 5 | ###Day 1### 6 | Intros, interview discussion 7 | Ask the laundry question 8 | Ask the coffee shop question 9 | Talk about the deck of cards question 10 | A lecture will be given on basic problem solving, and whiteboard strategy. A few problems will be worked through. Students will attempt exercises on paper using the time limits provided. Once students solve a set of problems, they should perform their solutions on a whiteboard and be able to explain their thought process to a group of their peers in groups of 3-5. 11 | 12 | ###Day 2### 13 | A lecture on Big O notation will be given, and several improvements to problems that have been solved will be discussed in terms of efficiency. Further exercises in Section 1 should be worked. Interview material is given to students to practice being the interviewer, and the interviewee. Students should not attempt to give the problem as an interviewer until they have first solved the problem. 14 | 15 | ###Day 3### 16 | Students share the insights they've gained from giving interviews to one another. Several problems will be discussed in terms of their time complexity, and their space complexity. Students will continue to give each other interviews. 17 | 18 | 19 | ##Section 2## 20 | ###Day 1### 21 | A lecture is given on some data structures and their properties. 22 | Covered: 23 | * Dictionaries 24 | * Lists 25 | 26 | 27 | 28 | Notes for Day 1: 29 | Liz: 30 | Run the enterprise 31 | Focus on operations on the bridge 32 | between people 33 | 34 | Ashi: 35 | Roles - defines roles 36 | 37 | Liz: 38 | How would those people interact? 39 | 40 | Draw a distributed systems graph 41 | 42 | how would 2 ships interact 43 | 44 | here's a mission - from an actual star trek episode :D 45 | -------------------------------------------------------------------------------- /section1/List_Searching.md: -------------------------------------------------------------------------------- 1 | List Searching 2 | ============== 3 | In this module, students should be able to give the time complexity and space complexity of their function. They should also be able to improve on functions that operate in greater than linear time. 4 | 5 | ##Goals## 6 | 7 | * Familiarization with searching lists given criteria 8 | * Comfort with using list syntax on paper 9 | * List syntax fluency & built-in method memorization 10 | * len() 11 | * .append() / .extend() 12 | * List Slicing 13 | * reverse() 14 | * map() and set() 15 | * x in l / x not in l 16 | * Beginning Big O Notation 17 | * Whiteboarding 18 | * Iterating on a whiteboard solution 19 | * Refactoring a whiteboard solution 20 | 21 | 22 | ##Missing Number## 23 | Time Limit: 20 minutes 24 | Completion Target: 10 minutes 25 | ###Exercise### 26 | Write a function that takes a list as input. It is given that the list will contain every integer from 0..n+1, unordered, except one random integer. Return the missing integer. 27 | 28 | Examples: 29 | `[0,4,2,1]` -> `3` 30 | `[2,0,3]` -> `1` 31 | `[0,1,2,3,5,7,6]` -> `4` 32 | 33 | 34 | Solutions: 35 | ```python 36 | x = 5 37 | ``` 38 | 39 | ##Highest Int## 40 | Time Limit: 15 minutes 41 | Completion Target: 5 minutes 42 | ###Exercise### 43 | Given an unordered list of integers, return the highest value. 44 | 45 | Examples: 46 | `[5,4]` -> `5` 47 | `[4,5,-1,0,3,-15,12]` -> `12` 48 | `[0,-1,-1,-3,-2,0,-1]` -> `0` 49 | 50 | Solutions: 51 | ```python 52 | x = 5 53 | ``` 54 | 55 | ##Highly Divisible## 56 | Time Limit: 30 minutes 57 | Completion Target: 15 minutes 58 | ###Exercise### 59 | Given an ordered list of integers, find the integer that is divisible by the most other integers in the list. 60 | 61 | Examples: 62 | `[1,2,3,4,5,6,7]` -> `6` 63 | Because 6 can be divided by 2 and 3, which is the highest count of unique integers (2) 64 | `[1,2,3,4,5,6,7,8,9,10,11,12]` -> `12` 65 | Because 12 is divisible by 2,3,4,6, (4 unique integers) while everything else is only divisible by 2 unique integers found in the list. 66 | 67 | Solutions: 68 | ```python 69 | x = 5 70 | ``` 71 | 72 | ##Binary Search## 73 | Time Limit: 20 minutes 74 | Completion Target: 5 minutes 75 | ###Exercise### 76 | Given an ordered list of integers, and an integer to search for, return the index of the requested integer. Do this in sub-linear time. 77 | 78 | 79 | Examples: 80 | `[1,2,3,4,5,6,7,8], 4` -> `3` 81 | `[5,10,15,20,25,30], 10` -> `1` 82 | `[3,6,9,12,15,18,21,24,27], 24` -> `7` 83 | 84 | 85 | Solutions: 86 | ```python 87 | x = 5 88 | ``` 89 | 90 | -------------------------------------------------------------------------------- /section1/List_Sorting.md: -------------------------------------------------------------------------------- 1 | List Sorting 2 | ============== 3 | Students should be able to implement several sorting algorithms, and be able to explain the time and space complexity of each sort. 4 | 5 | ##Goals## 6 | 7 | * Familiarization with sorting algorithms 8 | * Comfort writing and mentally testing algorithms 9 | * More Advanced Big O Notation 10 | 11 | ##Resources## 12 | http://stackoverflow.com/questions/471199/what-is-the-difference-between-n-and-on 13 | 14 | ##Bubble Sort## 15 | Time Limit: 20 minutes 16 | Completion Target: 10 minutes 17 | ###Exercise### 18 | Given an unordered list of integers, implement Bubble Sort, return the sorted list. 19 | What is the time complexity? 20 | What is the space complexity? 21 | 22 | Advanced: 23 | What is Big Omega? 24 | What is Big Theta? 25 | 26 | Examples: 27 | `[0,2,1,3,5]` -> `[0,1,2,3,5]` 28 | `[5,4,3,2,1]` -> `[1,2,3,4,5]` 29 | `[1,2,3,4,5]` -> `[1,2,3,4,5]` 30 | 31 | 32 | Solutions: 33 | ```python 34 | x = 5 35 | ``` 36 | 37 | ##Merge Sort## 38 | Time Limit: 40 minutes 39 | Completion Target: 15 minutes 40 | ###Exercise### 41 | Given an unordered list of integers, implement Merge Sort, return the sorted list. 42 | What is the time complexity? 43 | What is the space complexity? 44 | 45 | Advanced: 46 | What is Big Omega? 47 | What is Big Theta? 48 | 49 | 50 | Examples: 51 | `[0,2,1,3,5]` -> `[0,1,2,3,5]` 52 | `[5,4,3,2,1]` -> `[1,2,3,4,5]` 53 | `[1,2,3,4,5]` -> `[1,2,3,4,5]` 54 | 55 | Solutions: 56 | ```python 57 | x = 5 58 | ``` 59 | 60 | ##Quicksort## 61 | Time Limit: 40 minutes 62 | Completion Target: 20 minutes 63 | ###Exercise### 64 | Given an unordered list of integers, implement QuickSort, return the sorted list. 65 | What is the time complexity? 66 | What is the space complexity? 67 | 68 | Advanced: 69 | What is Big Omega? 70 | What is Big Theta? 71 | 72 | Examples: 73 | `[0,2,1,3,5]` -> `[0,1,2,3,5]` 74 | `[5,4,3,2,1]` -> `[1,2,3,4,5]` 75 | `[1,2,3,4,5]` -> `[1,2,3,4,5]` 76 | 77 | Solutions: 78 | ```python 79 | x = 5 80 | ``` 81 | 82 | ##Top 10## 83 | Time Limit: 20 minutes 84 | Completion Target: 5 minutes 85 | ###Exercise### 86 | Given an unordered list of integers, return the 10 highest integers. 87 | 88 | Advanced: 89 | How would you do this for a much larger array (EG, 10 million numbers? a trillion numbers?) 90 | 91 | 92 | Examples: 93 | `[2,9,88,8,24,27,4,6,63,1,34,6,48,9,55,2,21,25,52,75,80,50,56,86,25,9,68,86,32,742,6732,753,13,6,4,32,5,65,3,2]` 94 | -> `[65, 68, 75, 80, 86, 86, 88, 742, 753, 6732]` 95 | `[random.randint(1,10000000) for x in range(1,10000)]` -> `[9986018, 9988159, 9988505, 9989092, 9990058, 9991213, 9992473, 9993935, 9995767]` 96 | Note: you won't get these exact numbers 97 | 98 | Solutions: 99 | ```python 100 | x = 5 101 | ``` 102 | 103 | ##Pivot## 104 | Time Limit: 30 minutes 105 | Completion Target: 15 minutes 106 | ###Exercise### 107 | Given an unordered list of integers, find the median integer. Then, move all integers greater than the median integer to an index position greater than the median integer's position, and all integers lower than the median integer to an index position lower than the median integer's position. 108 | 109 | 110 | Examples: 111 | `[0,5,6,8,2,3,4,1,7]` -> `[0,2,3,1,4,5,6,8,7]` 112 | 4 is the pivot number, and the original order is preserved. 113 | 114 | 115 | Solutions: 116 | ```python 117 | x = 5 118 | ``` 119 | -------------------------------------------------------------------------------- /section1/Math_Problems.md: -------------------------------------------------------------------------------- 1 | Math Problems 2 | ============== 3 | 4 | 5 | ##Goals## 6 | 7 | * Familiarity with common math problems 8 | * Ability to write common inbuilt math functions 9 | * Increase usage of mathematical properties in problem solving 10 | 11 | ##Resources## 12 | 13 | 14 | ##Primes## 15 | Time Limit: 20 minutes 16 | Completion Target: 10 minutes 17 | ###Exercise### 18 | Given an integer, determine if the integer is prime. 19 | 20 | Advanced: 21 | Given an integer, return the nth prime number. 22 | 23 | Examples: 24 | `[0,2,1,3,5]` -> `[0,1,2,3,5]` 25 | `[5,4,3,2,1]` -> `[1,2,3,4,5]` 26 | `[1,2,3,4,5]` -> `[1,2,3,4,5]` 27 | 28 | 29 | Solutions: 30 | ```python 31 | x = 5 32 | ``` 33 | 34 | ##Factorial## 35 | Time Limit: 10 minutes 36 | Completion Target: 5 minutes 37 | ###Exercise### 38 | Given a number, return n! 39 | 40 | Examples: 41 | `5` -> 120 42 | `10` -> 3628800 43 | 44 | 45 | Solutions: 46 | ```python 47 | x = 5 48 | ``` 49 | 50 | ##List Factors## 51 | Time Limit: 20 minutes 52 | Completion Target: 10 minutes 53 | ###Exercise### 54 | Given a number, list it's prime factors 55 | 56 | Advanced: 57 | Given 2 numbers, list the greatest common factor 58 | 59 | Examples: 60 | 61 | 62 | 63 | Solutions: 64 | ```python 65 | x = 5 66 | ``` 67 | 68 | ##Fibonacci## 69 | ###Exercise### 70 | 1. Fibonacci with recursion 71 | Given n, return a sequence of fibonacci numbers that is of length n. Solve this using recursion. 72 | 2. Fibonacci iteratively 73 | Given n, return a sequence of fibonacci numbers that is of length n. Solve this iteratively. 74 | 3. Fibonacci at scale 75 | Given n, return a sequence of fibonacci numbers that is of length n. Solve this, but so that subsequent calls to this function do not require recalculation. 76 | 77 | Examples: 78 | `5` -> `[1,1,2,3,5]` 79 | `15` -> `[1,1,2,3,5,8,13,21,34,55,89,144,233,377]` 80 | 81 | Solutions: 82 | ```python 83 | x = 5 84 | ``` -------------------------------------------------------------------------------- /section1/Recursion.md: -------------------------------------------------------------------------------- 1 | Recursion 2 | ============== 3 | 4 | 5 | ##Goals## 6 | 7 | * Familiarity with recursion 8 | * Tail Recursion 9 | * Understanding of stack space 10 | * Familiarity with recursion 11 | * Familiarity with recursion 12 | * Familiarity with recursion 13 | 14 | 15 | ##Resources## 16 | 17 | 18 | ##Fibonacci Recursion## 19 | Time Limit: 15 minutes 20 | Completion Target: 5 minutes 21 | ###Exercise### 22 | Given a number n, return a list containing a sequence of n fibonacci numbers starting with 1. This should be implemented recursively. 23 | 24 | 25 | Advanced: 26 | Return only the nth fibonacci number, using recursion 27 | 28 | Examples: 29 | `5` -> `[1,1,2,3,5]` 30 | `7` -> `[1,1,2,3,5,8,13]` 31 | `9` -> `[1,1,2,3,5,8,13,21,34]` 32 | 33 | 34 | Solutions: 35 | ```python 36 | x = 5 37 | ``` 38 | 39 | ##Recursive List Length## 40 | Time Limit: 15 minutes 41 | Completion Target: 5 minutes 42 | ###Exercise### 43 | Given a list, return it's length using recursion 44 | 45 | Examples: 46 | `[9,5,6,7,8]` -> `5` 47 | `['1', 'a', '15', 55, 99, 'qux', 'baz']` -> `7` 48 | 49 | 50 | Solutions: 51 | ```python 52 | x = 5 53 | ``` 54 | 55 | ##Recursive List Reverse## 56 | Time Limit: 25 minutes 57 | Completion Target: 10 minutes 58 | ###Exercise### 59 | Given a list, return a reversed copy of that list, using recursion 60 | 61 | 62 | Examples: 63 | `[5,4,3,2,1]` -> `[1,2,3,4,5]` 64 | `['a', 'b', 'c']` -> `['c', 'b', 'a']` 65 | 66 | Solutions: 67 | ```python 68 | x = 5 69 | ``` 70 | 71 | ##Recursive List Find## 72 | Time Limit: 20 minutes 73 | Completion Target: 5 minutes 74 | ###Exercise### 75 | Given a list and a value to search for, return the index of that value, using recursion 76 | 77 | 78 | Examples: 79 | [7,8,9,10,11,12,13,14], 10 -> 3 80 | ['a', 'b', 'c', 'd', 'e', 'f'], 'e' -> 4 81 | 82 | 83 | Solutions: 84 | ```python 85 | x = 5 86 | ``` -------------------------------------------------------------------------------- /section1/String_Parsing.md: -------------------------------------------------------------------------------- 1 | String Parsing 2 | ======= 3 | ##Goals## 4 | * Familiarization with coding on paper 5 | * Being comfortable with different solutions 6 | * Ability to complete these tasks in less than 5 minutes each 7 | * Comfort solving problems on the board 8 | 9 | 10 | ##Reverse## 11 | Time Limit: 10 minutes 12 | Completion Target: 5 minutes 13 | ###Exercise### 14 | Write a function that accepts a string as input. It should return that string, reversed. You are not allowed to use inbuilt methods. 15 | 16 | Examples: 17 | `"abc"` -> `"cba"` 18 | `"cats"` -> `"stac"` 19 | 20 | Solutions: 21 | 22 | ```python 23 | def reverse(s): 24 | new_str = "" 25 | for i in range(len(s)): 26 | new_str += s[i*-1] 27 | return new_str 28 | 29 | ``` 30 | 31 | ##Palindromes## 32 | Time Limit: 15 minutes 33 | Completion Target: 5 minutes 34 | ###Exercise### 35 | Write a function that accepts a string as input. It should return a boolean. True, if the string is a Palindrome. False, if the string is not. A Palindrome is the same string backwards and forwards, independent of case or spaces. 36 | 37 | 38 | Examples: 39 | `"A Toyotas a Toyota"` -> `True` 40 | `"otto"` -> `True` 41 | `"Godzilla!"` -> `False` 42 | `"Hostess"` -> `False` 43 | 44 | Solutions: 45 | ```python 46 | def palindrome(s): 47 | clean_string = s.lower().replace(" ", "") 48 | if clean_string == clean_string[::-1]: 49 | return True 50 | return False 51 | ``` 52 | 53 | 54 | ##Substr## 55 | ###Exercise### 56 | Time Limit: 15 minutes 57 | Completion Target: 5 minutes 58 | Write a function that accepts 2 strings as input. The function should search the first string for any occurrence of the second string. 59 | The function should return the index of the first occurrence of the second string within the first string. If the string has no occurrences, the function should return -1. 60 | 61 | Examples: 62 | `"abcdef", "de"` -> `3` 63 | `"quartz crystals", "z c"` -> `5` 64 | `"Spanish Inquisition", "Nobody expects"` -> `-1` 65 | 66 | Solutions: 67 | ```python 68 | 69 | ``` 70 | 71 | ##Split## 72 | Time Limit: 15 minutes 73 | Completion Target: 7-10 minutes 74 | ###Exercise### 75 | Write a function that accepts 2 strings as input. The function should return a list based on dividing the first string by the second string. It should mimic the behavior of str.split(). If no character is passed in, the function should return the string divided by each character (ie, a list version of the string.) 76 | 77 | Examples: 78 | `"Hello my name is Liz", " "` -> `["Hello", "my", "name", "is", "Liz"]` 79 | `"'Holy Smurf!' said Poppa Smurf, because the Smurfberries were gone!", "Smurf"` -> `["'Holy ", "!' said Poppa", ", because the ", "berries were gone!"]` 80 | `"abcd"` -> `["a", "b", "c", "d"]` 81 | `"hello all you happy people", "droopy"` -> `["hello all you happy people"]` 82 | 83 | Solutions: 84 | ```python 85 | 86 | ``` -------------------------------------------------------------------------------- /section3/Linked_Lists.md: -------------------------------------------------------------------------------- 1 | Linked Lists 2 | ============ 3 | Students should be given a notation like this: 4 | ```python 5 | Node 6 | Data 7 | Next 8 | 9 | SinglyLinkedList 10 | Head 11 | ``` 12 | and a brief explanation of linked lists. Diagrams should be drawn. 13 | 14 | 15 | ##Goals## 16 | 17 | ##Resources## 18 | 19 | 20 | ##Find Tail## 21 | Given a singly linked list, implement a method that returns the tail (last node, whose "next" attribute points to None). 22 | 23 | 24 | 25 | ##Find Length## 26 | Given a singly linked list, return the count of nodes in the linked list. Assume the list is not circular and contains no loops. 27 | 28 | ##Find Index## 29 | Given a singly linked list and an index, return the node at that index. 30 | 31 | ##Insert## 32 | Given a singly linked list, an index, and a node, insert the node at the specified index. 33 | 34 | ##Delete## 35 | Given a singly linked list and an index, delete the node at the specified index, while not losing the rest of the list. 36 | 37 | ##Find Circles## 38 | Given a singly linked list, return True if the list is circular. Return False if it is not. A list is circular if any node points at the node referenced by SinglyLinkedList.head. 39 | 40 | ##Find Loops## 41 | Given a singly linked list, return True if any node points to a previous node in the list. 42 | 43 | ##Find Kth Element## 44 | Given a singly linked list and a number K, return the Kth element from the end in the list. If there are fewer than K elements in the list, return False. 45 | 46 | -------------------------------------------------------------------------------- /test.py: -------------------------------------------------------------------------------- 1 | def palindrome(s): 2 | clean_string = s.lower().replace(" ", "") 3 | if clean_string == clean_string[::-1]: 4 | return True 5 | return False --------------------------------------------------------------------------------