The REACTO approach as described in Sarah Katz’s Medium article
| Step | Description | Suggestions |
| Repeat | Repeat the question, in your own words, to make sure you understand the problem. You are also encouraged to ask questions during this portion of the interview, to ensure that you have all of the information necessary to solve the problem. | Seriously… your own words. This step might bleed into the next one and that’s okay |
| Examples | Examples. At this point you are encouraged to create some example inputs and what the expected output would be. It’s important to also create examples of any edge cases you might expect to encounter. | Try to get specific. Think about the quirks of your language (what’s truthy?) and nil cases especially. |
| Approach | Approach. The next step is to plan (and communicate) your approach to the problem. There is no coding involved in this step, just thinking out (and articulating) what you plan to do. | Do some pseudocoding and don’t forget to talk out loud. If you’re unsure of something, it doesn’t hurt to say you’ve thought of a case and are still considering it. |
| Code | Code out your solution. Trying as best as you can to following your approach from step #4, write code (actual or pseudo) to solve the problem. | DON’T STOP TALKING. If you need to blackbox a part of your code in order to keep making progress, do that and come back to it. |
| Test | Test your code. Using the examples you wrote earlier, run each example through your code (making sure you’re running it through the code you actually wrote, not what you think you wrote) and see if you get the expected output. | Use at least one typical/easy case and at least one edge case. |
| Optimize | Optimize your code. Once you’ve found a working solution, you can go back and optimize it — make it DRY, improve the time and/or space complexity, and do anything else that will improve your code. | Talk through the Big O of your solution. It doesn’t hurt to mention Big O earlier, especially if you know your strategy is not the best but want to use it first. Even if you’re not sure the best way to optimize, demonstrate that you know where optimizations need to be. |
Write a function called
`hasTargetSum` that receives two arguments:
* an array of integers
* a target integer
The function should return all pairs of numbers found in the array that add up to the target number.
hasTargetSum([-1, 3, 8, 12, 4, 11, 7], 10) ==> [[-1, 11], [3, 7]]
-
What is an algorithm? specific set of steps that yield the same results logical approach
-
How do we measure time? with clocks ==> hours, minutes, seconds, etc. re: computers maybe but milliseconds instead of time ie minutes, seconds, etc. computations
-
What cases are we concerned with? 100000000000000 WORST CASE SCENARIO AS WE GET MORE AND MORE DATA, HOW DOES OUR ALGORITHM PERFORM?
-
How to write our Big O Notation
-
Types of Big O to cover
- Constant O(1) ===> don't matta how much data
- Logarithmic O(log(n))
- Linear O(n) ===> as the data grows, the computations grow linearlyy
- Quadratic O(n^2) ==> as the data grows, the computations grow quadratically
- Exponential O(2^n) ie recursive fibonacci
- Factorial O(n!) ie traveling salesman problem
-
Lists & Objects && Big O Notation