├── .gitignore ├── LICENSE ├── README.md └── challenges ├── README.md └── typescript ├── README.md ├── challenges ├── challenges.test.ts ├── insertionSort.ts ├── mergeSort.ts ├── quickSort.ts └── selectionSort.ts ├── mocha.opts ├── package-lock.json ├── package.json ├── solutions ├── insertionSort.ts ├── mergeSort.ts ├── quickSort.ts └── selectionSort.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Tristan Siegel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tech Interview Cheat Sheet 2 | 3 | This list is meant to be both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. 4 | 5 | ## Contributing 6 | This is an open source, community project, and I am grateful for all the help I can get. If you find a mistake make a PR and please have a source so I can confirm the correction. If you have any suggestions feel free to open an issue. 7 | 8 | ## Challenges 9 | This project now has actual code challenges! This challenges are meant to cover the topics you'll read below. Maybe you'll see them in an interview and maybe you won't. Either way you'll probably learn something new. [Click here for more](./challenges/README.md) 10 | 11 | # Table of Content 12 | - [Asymptotic Notation](#asymptotic-notation) 13 | - [Data Structures](#data-structures) 14 | - [Array](#array) 15 | - [Linked List](#linked-list) 16 | - [Hash Table or Hash Map](#hash) 17 | - [Binary Tree](#binary-tree) 18 | - [Algorithms](#algorithms) 19 | - [Algorithm Basics](#algorithm-basics) 20 | - [Search Algorithms](#search-algorithms) 21 | - [Breadth First Search](#breadth-first-search) 22 | - [Depth First Search](#depth-first-search) 23 | - [Sorting Algorithms](#sorting-algorithms) 24 | - [Selection Sort](#selection-sort) 25 | - [Insertion Sort](#insertion-sort) 26 | - [Merge Sort](#merge-sort) 27 | - [Quick Sort](#quick-sort) 28 | - [Additional Resources](#additional-resources) 29 | 30 | 31 | # Asymptotic Notation 32 | ### Definition: 33 | Asymptotic Notation is the hardware independent notation used to tell the time and space complexity of an algorithm. Meaning it's a standardized way of measuring how much memory an algorithm uses or how long it runs for given an input. 34 | 35 | #### Complexities 36 | The following are the Asymptotic rates of growth from best to worst: 37 | - constant growth - ``O(1)`` Runtime is constant and does not grow with `n` 38 | - logarithmic growth – ``O(log n)`` Runtime grows logarithmically in proportion to `n` 39 | - linear growth – ``O(n)`` Runtime grows directly in proportion to `n` 40 | - superlinear growth – ``O(n log n)`` Runtime grows in proportion _and_ logarithmically to `n` 41 | - polynomial growth – `O(n^c)` Runtime grows quicker than previous all based on `n` 42 | - exponential growth – `O(c^n)` Runtime grows even faster than polynomial growth based on `n` 43 | - factorial growth – `O(n!)` Runtime grows the fastest and becomes quickly unusable for even 44 | small values of `n` 45 | 46 | [(source: Soumyadeep Debnath, _Analysis of Algorithms | Big-O analysis_)](https://www.geeksforgeeks.org/analysis-algorithms-big-o-analysis/) 47 | 48 | Visualized below; the x-axis representing input size and the y-axis representing complexity: 49 | 50 | ![#](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Comparison_computational_complexity.svg/400px-Comparison_computational_complexity.svg.png) 51 | 52 | [(source: Wikipedia, _Computational Complexity of Mathematical Operations_)](https://en.wikipedia.org/wiki/Computational_complexity_of_mathematical_operations) 53 | 54 | #### Big-O notation 55 | Big-O refers to the upper bound of time or space complexity of an algorithm, meaning it worst case runtime scenario. An easy way to think of it is that runtime could be better than Big-O but it will never be worse. 56 | #### Big-Ω (Big-Omega) notation 57 | Big-Omega refers to the lower bound of time or space complexity of an algorithm, meaning it is the best runtime scenario. Or runtime could worse than Big-Omega, but it will never be better. 58 | #### Big-θ (Big-Theta) notation 59 | Big-Theta refers to the tight bound of time or space complexity of an algorithm. Another way to think of it is the intersection of Big-O and Big-Omega, or more simply runtime is guaranteed to be a given complexity, such as `n log n`. 60 | 61 | #### What you need to know 62 | - Big-O and Big-Theta are the most common and helpful notations 63 | - Big-O does _not_ mean Worst Case Scenario, Big-Theta does _not_ mean average case, and Big-Omega does _not_ mean Best Case Scenario. They only connote the algorithm's performance for a particular scenario, and all three can be used for any scenario. 64 | - Worst Case means given an unideal input, Average Case means given a typical input, Best case means a ideal input. Ex. Worst case means given an input the algorithm performs particularly bad, or best case an already sorted array for a sorting algorithm. 65 | - Best Case and Big Omega are generally not helpful since Best Cases are rare in the real world and lower bound might be very different than an upper bound. 66 | - Big-O isn't everything. On paper merge sort is faster than quick sort, but in practice quick sort is superior. 67 | 68 | # Data Structures 69 | ### Array 70 | #### Definition 71 | - Stores data elements based on an sequential, most commonly 0 based, index. 72 | - Based on [tuples](http://en.wikipedia.org/wiki/Tuple) from set theory. 73 | - They are one of the oldest, most commonly used data structures. 74 | 75 | #### What you need to know 76 | - Optimal for indexing; bad at searching, inserting, and deleting (except at the end). 77 | - **Linear arrays**, or one dimensional arrays, are the most basic. 78 | - Are static in size, meaning that they are declared with a fixed size. 79 | - **Dynamic arrays** are like one dimensional arrays, but have reserved space for additional elements. 80 | - If a dynamic array is full, it copies its contents to a larger array. 81 | - **Multi dimensional arrays** nested arrays that allow for multiple dimensions such as an array of arrays providing a 2 dimensional spacial representation via x, y coordinates. 82 | 83 | #### Time Complexity 84 | - Indexing: Linear array: `O(1)`, Dynamic array: `O(1)` 85 | - Search: Linear array: `O(n)`, Dynamic array: `O(n)` 86 | - Optimized Search: Linear array: `O(log n)`, Dynamic array: `O(log n)` 87 | - Insertion: Linear array: n/a, Dynamic array: `O(n)` 88 | 89 | 90 | ### Linked List 91 | #### Definition 92 | - Stores data with **nodes** that point to other nodes. 93 | - Nodes, at its most basic it has one datum and one reference (another node). 94 | - A linked list _chains_ nodes together by pointing one node's reference towards another node. 95 | 96 | #### What you need to know 97 | - Designed to optimize insertion and deletion, slow at indexing and searching. 98 | - **Doubly linked list** has nodes that also reference the previous node. 99 | - **Circularly linked list** is simple linked list whose **tail**, the last node, references the **head**, the first node. 100 | - **Stack**, commonly implemented with linked lists but can be made from arrays too. 101 | - Stacks are **last in, first out** (LIFO) data structures. 102 | - Made with a linked list by having the head be the only place for insertion and removal. 103 | - **Queues**, too can be implemented with a linked list or an array. 104 | - Queues are a **first in, first out** (FIFO) data structure. 105 | - Made with a linked list that only removes from head and adds to tail. 106 | 107 | #### Time Complexity 108 | - Indexing: Linked Lists: `O(n)` 109 | - Search: Linked Lists: `O(n)` 110 | - Optimized Search: Linked Lists: `O(n)` 111 | - Append: Linked Lists: `O(1)` 112 | - Prepend: Linked Lists: `O(1)` 113 | - Insertion: Linked Lists: `O(n)` 114 | 115 | 116 | ### Hash Table or Hash Map 117 | #### Definition 118 | - Stores data with key value pairs. 119 | - **Hash functions** accept a key and return an output unique only to that specific key. 120 | - This is known as **hashing**, which is the concept that an input and an output have a one-to-one correspondence to map information. 121 | - Hash functions return a unique address in memory for that data. 122 | 123 | #### What you need to know 124 | - Designed to optimize searching, insertion, and deletion. 125 | - **Hash collisions** are when a hash function returns the same output for two distinct inputs. 126 | - All hash functions have this problem. 127 | - This is often accommodated for by having the hash tables be very large. 128 | - Hashes are important for associative arrays and database indexing. 129 | 130 | #### Time Complexity 131 | - Indexing: Hash Tables: `O(1)` 132 | - Search: Hash Tables: `O(1)` 133 | - Insertion: Hash Tables: `O(1)` 134 | 135 | 136 | ### Binary Tree 137 | #### Definition 138 | - Is a tree like data structure where every node has at most two children. 139 | - There is one left and right child node. 140 | 141 | For a full binary-tree reference see [Here](https://www.scaler.com/topics/data-structures/binary-tree-in-data-structure/) 142 | 143 | #### What you need to know 144 | - Designed to optimize searching and sorting. 145 | - A **degenerate tree** is an unbalanced tree, which if entirely one-sided, is essentially a linked list. 146 | - They are comparably simple to implement than other data structures. 147 | - Used to make **binary search trees**. 148 | - A binary tree that uses comparable keys to assign which direction a child is. 149 | - Left child has a key smaller than its parent node. 150 | - Right child has a key greater than its parent node. 151 | - There can be no duplicate node. 152 | - Because of the above it is more likely to be used as a data structure than a binary tree. 153 | 154 | #### Time Complexity 155 | - Indexing: Binary Search Tree: `O(log n)` 156 | - Search: Binary Search Tree: `O(log n)` 157 | - Insertion: Binary Search Tree: `O(log n)` 158 | 159 | 160 | # Algorithms 161 | ## Algorithm Basics 162 | ### Recursive Algorithms 163 | #### Definition 164 | - An algorithm that calls itself in its definition. 165 | - **Recursive case** a conditional statement that is used to trigger the recursion. 166 | - **Base case** a conditional statement that is used to break the recursion. 167 | 168 | #### What you need to know 169 | - **Stack level too deep** and **stack overflow**. 170 | - If you've seen either of these from a recursive algorithm, you messed up. 171 | - It means that your base case was never triggered because it was faulty or the problem was so massive you ran out of alloted memory. 172 | - Knowing whether or not you will reach a base case is integral to correctly using recursion. 173 | - Often used in Depth First Search 174 | 175 | 176 | ### Iterative Algorithms 177 | #### Definition 178 | - An algorithm that is called repeatedly but for a finite number of times, each time being a single iteration. 179 | - Often used to move incrementally through a data set. 180 | 181 | #### What you need to know 182 | - Generally you will see iteration as loops, for, while, and until statements. 183 | - Think of iteration as moving one at a time through a set. 184 | - Often used to move through an array. 185 | 186 | #### Recursion Vs. Iteration 187 | - The differences between recursion and iteration can be confusing to distinguish since both can be used to implement the other. But know that, 188 | - Recursion is, usually, more expressive and easier to implement. 189 | - Iteration uses less memory. 190 | - **Functional languages** tend to use recursion. (i.e. Haskell) 191 | - **Imperative languages** tend to use iteration. (i.e. Ruby) 192 | - Check out this [Stack Overflow post](http://stackoverflow.com/questions/19794739/what-is-the-difference-between-iteration-and-recursion) for more info. 193 | 194 | #### Pseudo Code of Moving Through an Array 195 | ``` 196 | Recursion | Iteration 197 | ----------------------------------|---------------------------------- 198 | recursive method (array, n) | iterative method (array) 199 | if array[n] is not nil | for n from 0 to size of array 200 | print array[n] | print(array[n]) 201 | recursive method(array, n+1) | 202 | else | 203 | exit loop | 204 | ``` 205 | 206 | ### Greedy Algorithms 207 | #### Definition 208 | - An algorithm that, while executing, selects only the information that meets a certain criteria. 209 | - The general five components, taken from [Wikipedia](http://en.wikipedia.org/wiki/Greedy_algorithm#Specifics): 210 | - A candidate set, from which a solution is created. 211 | - A selection function, which chooses the best candidate to be added to the solution. 212 | - A feasibility function, that is used to determine if a candidate can be used to contribute to a solution. 213 | - An objective function, which assigns a value to a solution, or a partial solution. 214 | - A solution function, which will indicate when we have discovered a complete solution. 215 | 216 | #### What you need to know 217 | - Used to find the expedient, though non-optimal, solution for a given problem. 218 | - Generally used on sets of data where only a small proportion of the information evaluated meets the desired result. 219 | - Often a greedy algorithm can help reduce the Big O of an algorithm. 220 | 221 | #### Pseudo Code of a Greedy Algorithm to Find Largest Difference of any Two Numbers in an Array. 222 | ``` 223 | greedy algorithm (array) 224 | var largest difference = 0 225 | var new difference = find next difference (array[n], array[n+1]) 226 | largest difference = new difference if new difference is > largest difference 227 | repeat above two steps until all differences have been found 228 | return largest difference 229 | ``` 230 | 231 | This algorithm never needed to compare all the differences to one another, saving it an entire iteration. 232 | 233 | ## Search Algorithms 234 | ### Breadth First Search 235 | #### Definition 236 | - An algorithm that searches a tree (or graph) by searching levels of the tree first, starting at the root. 237 | - It finds every node on the same level, most often moving left to right. 238 | - While doing this it tracks the children nodes of the nodes on the current level. 239 | - When finished examining a level it moves to the left most node on the next level. 240 | - The bottom-right most node is evaluated last (the node that is deepest and is farthest right of it's level). 241 | 242 | #### What you need to know 243 | - Optimal for searching a tree that is wider than it is deep. 244 | - Uses a queue to store information about the tree while it traverses a tree. 245 | - Because it uses a queue it is more memory intensive than **depth first search**. 246 | - The queue uses more memory because it needs to stores pointers 247 | 248 | #### Time Complexity 249 | - Search: Breadth First Search: O(V + E) 250 | - E is number of edges 251 | - V is number of vertices 252 | 253 | ### Depth First Search 254 | #### Definition 255 | - An algorithm that searches a tree (or graph) by searching depth of the tree first, starting at the root. 256 | - It traverses left down a tree until it cannot go further. 257 | - Once it reaches the end of a branch it traverses back up trying the right child of nodes on that branch, and if possible left from the right children. 258 | - When finished examining a branch it moves to the node right of the root then tries to go left on all it's children until it reaches the bottom. 259 | - The right most node is evaluated last (the node that is right of all it's ancestors). 260 | 261 | #### What you need to know 262 | - Optimal for searching a tree that is deeper than it is wide. 263 | - Uses a stack to push nodes onto. 264 | - Because a stack is LIFO it does not need to keep track of the nodes pointers and is therefore less memory intensive than breadth first search. 265 | - Once it cannot go further left it begins evaluating the stack. 266 | 267 | #### Time Complexity 268 | - Search: Depth First Search: O(|E| + |V|) 269 | - E is number of edges 270 | - V is number of vertices 271 | 272 | 273 | #### Breadth First Search Vs. Depth First Search 274 | - The simple answer to this question is that it depends on the size and shape of the tree. 275 | - For wide, shallow trees use Breadth First Search 276 | - For deep, narrow trees use Depth First Search 277 | 278 | #### Nuances 279 | - Because BFS uses queues to store information about the nodes and its children, it could use more memory than is available on your computer. (But you probably won't have to worry about this.) 280 | - If using a DFS on a tree that is very deep you might go unnecessarily deep in the search. See [xkcd](http://xkcd.com/761/) for more information. 281 | - Breadth First Search tends to be a looping algorithm. 282 | - Depth First Search tends to be a recursive algorithm. 283 | 284 | 285 | ## Sorting Algorithms 286 | 287 | ### Selection Sort 288 | #### Definition 289 | - A comparison based sorting algorithm. 290 | - Starts with the cursor on the left, iterating left to right 291 | - Compares the left side to the right, looking for the smallest known item 292 | - If the left is smaller than the item to the right it continues iterating 293 | - If the left is bigger than the item to the right, the item on the right becomes the known smallest number 294 | - Once it has checked all items, it moves the known smallest to the cursor and advances the cursor to the right and starts over 295 | - As the algorithm processes the data set, it builds a fully sorted left side of the data until the entire data set is sorted 296 | - Changes the array in place. 297 | 298 | #### What you need to know 299 | - Inefficient for large data sets. 300 | - Very simple to implement. 301 | 302 | #### Time Complexity 303 | - Best Case Sort: `O(n^2)` 304 | - Average Case Sort: `O(n^2)` 305 | - Worst Case Sort: `O(n^2)` 306 | 307 | #### Space Complexity 308 | - Worst Case: `O(1)` 309 | 310 | #### Visualization 311 | ![#](https://upload.wikimedia.org/wikipedia/commons/9/94/Selection-Sort-Animation.gif) 312 | 313 | [(source: Wikipedia, _Selection Sort_)](https://en.wikipedia.org/wiki/Selection_sort) 314 | 315 | ### Insertion Sort 316 | #### Definition 317 | - A comparison based sorting algorithm. 318 | - Iterates left to right comparing the current cursor to the previous item. 319 | - If the cursor is smaller than the item on the left it swaps positions and the cursor compares itself again to the left hand side until it is put in its sorted position. 320 | - As the algorithm processes the data set, the left side becomes increasingly sorted until it is fully sorted. 321 | - Changes the array in place. 322 | 323 | #### What you need to know 324 | - Inefficient for large data sets, but can be faster for than other algorithms for small ones. 325 | - Although it has an `O(n^2)` time complexity, in practice it is slightly less since its comparison scheme only requires checking place if it is smaller than its neighbor. 326 | 327 | #### Time Complexity 328 | - Best Case: `O(n)` 329 | - Average Case: `O(n^2)` 330 | - Worst Case: `O(n^2)` 331 | 332 | #### Space Complexity 333 | - Worst Case: `O(n)` 334 | 335 | #### Visualization 336 | ![#](https://upload.wikimedia.org/wikipedia/commons/0/0f/Insertion-sort-example-300px.gif) 337 | 338 | [(source: Wikipedia, _Insertion Sort_)](https://en.wikipedia.org/wiki/Insertion_sort) 339 | 340 | ### Merge Sort 341 | #### Definition 342 | - A divide and conquer algorithm. 343 | - Recursively divides entire array by half into subsets until the subset is one, the base case. 344 | - Once the base case is reached results are returned and sorted ascending left to right. 345 | - Recursive calls are returned and the sorts double in size until the entire array is sorted. 346 | 347 | #### What you need to know 348 | - This is one of the fundamental sorting algorithms. 349 | - Know that it divides all the data into as small possible sets then compares them. 350 | 351 | #### Time Complexity 352 | - Worst Case: `O(n log n)` 353 | - Average Case: `O(n log n)` 354 | - Best Case: `O(n)` 355 | 356 | #### Space Complexity 357 | - Worst Case: `O(1)` 358 | 359 | #### Visualization 360 | ![#](https://upload.wikimedia.org/wikipedia/commons/thumb/e/e6/Merge_sort_algorithm_diagram.svg/400px-Merge_sort_algorithm_diagram.svg.png) 361 | 362 | [(source: Wikipedia, _Merge Sort_)](https://en.wikipedia.org/wiki/Merge_sort) 363 | 364 | ### Quicksort 365 | #### Definition 366 | - A divide and conquer algorithm 367 | - Partitions entire data set in half by selecting a random pivot element and putting all smaller elements to the left of the element and larger ones to the right. 368 | - It repeats this process on the left side until it is comparing only two elements at which point the left side is sorted. 369 | - When the left side is finished sorting it performs the same operation on the right side. 370 | - Computer architecture favors the quicksort process. 371 | - Changes the array in place. 372 | 373 | #### What you need to know 374 | - While it has the same Big O as (or worse in some cases) many other sorting algorithms it is often faster in practice than many other sorting algorithms, such as merge sort. 375 | 376 | #### Time Complexity 377 | - Worst Case: `O(n^2)` 378 | - Average Case: `O(n log n)` 379 | - Best Case: `O(n log n)` 380 | 381 | #### Space Complexity 382 | - Worst Case: `O(log n)` 383 | 384 | #### Visualization 385 | ![#](https://upload.wikimedia.org/wikipedia/commons/6/6a/Sorting_quicksort_anim.gif) 386 | 387 | [(source: Wikipedia, _Quicksort_)](https://en.wikipedia.org/wiki/Quicksort) 388 | 389 | #### Merge Sort Vs. Quicksort 390 | - Quicksort is likely faster in practice, but merge sort is faster on paper. 391 | - Merge Sort divides the set into the smallest possible groups immediately then reconstructs the incrementally as it sorts the groupings. 392 | - Quicksort continually partitions the data set by a pivot, until the set is recursively sorted. 393 | 394 | ## Additional Resources 395 | [Khan Academy's Algorithm Course](https://www.khanacademy.org/computing/computer-science/algorithms) 396 | [Graph Data Structure & Algorithms](https://www.interviewbit.com/courses/programming/graph-data-structure-algorithms/) 397 | [Data Structure Interview Questions](https://www.interviewbit.com/data-structure-interview-questions/) 398 | [Data Structure MCQ With Answers](https://www.interviewbit.com/data-structure-mcq/) 399 | [10 Best Data Structures and Algorithms Books](https://www.interviewbit.com/blog/data-structures-and-algorithms-books/) 400 | -------------------------------------------------------------------------------- /challenges/README.md: -------------------------------------------------------------------------------- 1 | # Tech Interview Cheat Sheet Challenges 2 | ## Overview 3 | These challenges are meant to give you some examples of something you might see on an interviewing challenge. But more broadly, to help you stay sharp and help clarify some of the content on the Cheat Sheets main [README](https://github.com/TSiege/Tech-Interview-Cheat-Sheet). The challenges are divided into different languages (if you don't see yours below [make a pr](#contributing)). 4 | 5 | The way they work is simple. Open up whatever language you're interested in and follow the README. As a note, the tests are designed to be followed in the order they run. 6 | 7 | Each language will have the following directory set up in common: (any other files you see are to simply make it work) 8 | ``` 9 | / 10 | |- README.md This explains how to get it working on your machine and how to run the tests 11 | \- challenges/ This directory has the challenges broken into different files, waiting for you to make them work 12 | \- solutions/ This directory has the (suggested) solutions to the challenges in the same file structure as challenges/ 13 | ``` 14 | 15 | ## Languages 16 | [TypeScript/JavaScript](./typescript) 17 | 18 | ## Contributing 19 | The plan is to have the same challenges in multiple languages to help you expand or refresh your memory on how to use one. However, I can't do them all myself, so if you see your language is missing feel free to open a PR and contribute them. My only rules are use sensible variable names. Naming all your variables one letter isn't helping anyone, and it inhibits learning. And follow the set up for how the existing ones work. 20 | 21 | ## Sources 22 | Many of these exercises are taken from [Khan Academy's Fantastic Course on Algorithms](https://www.khanacademy.org/computing/computer-science/algorithms). I highly recommend it if you're feeling lost or just want to learn more in general. 23 | -------------------------------------------------------------------------------- /challenges/typescript/README.md: -------------------------------------------------------------------------------- 1 | # Tech Interview Cheat Sheet TypeScript/JavaScript Challenges 2 | 3 | ## Overview 4 | These tests and their files are written in TypeScript, but you don't even need to know TypeScript to use them. The functions are already set up with the needed declarations. All you need to do is fill them in to make them pass the tests. 5 | 6 | The tests are set up to fail fast, meaning as soon as one test fails no other tests after it run. This is meant to help you keep focused the current test at hand. 7 | 8 | ## Getting Started 9 | It's really this simple! 10 | ```bash 11 | git clone git@github.com:TSiege/Tech-Interview-Cheat-Sheet.git 12 | cd ./Tech-Interview-Cheat-Sheet/challenges/typescript 13 | npm install 14 | npm test 15 | ``` 16 | -------------------------------------------------------------------------------- /challenges/typescript/challenges/challenges.test.ts: -------------------------------------------------------------------------------- 1 | import { assert } from 'chai' 2 | import { swap as selectionSwap, indexOfMinimum, selectionSort } from './selectionSort' 3 | import { insert, insertionSort } from './insertionSort' 4 | import { merge, mergeSort } from './mergeSort' 5 | import { swap as quickSwap, partition , quickSort } from './quickSort' 6 | 7 | describe('Challenges', () => { 8 | describe('Selection Sort', () => { 9 | describe('swap', () => { 10 | it('swaps position of two items in an array given their indices', () => { 11 | const arr = [4, 3, 2, 1] 12 | selectionSwap(arr, 0, 3) 13 | assert.deepEqual(arr, [1, 3, 2, 4]) 14 | selectionSwap(arr, 1, 2) 15 | assert.deepEqual(arr, [1, 2, 3, 4]) 16 | }) 17 | }) 18 | describe('indexOfMinimum', () => { 19 | it('finds the index of the smallest item from a given starting point', () => { 20 | assert.deepEqual(indexOfMinimum([1, 2, 3], 0), 0) 21 | assert.deepEqual(indexOfMinimum([1, 2, 3], 1), 1) 22 | assert.deepEqual(indexOfMinimum([1, 2, 3], 2), 2) 23 | }) 24 | }) 25 | describe('selectionSort', () => { 26 | it('sorts an array in place', () => { 27 | const arr1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] 28 | const arr2 = [56, 34, 103, -1, 11, 0, -23, 10, 75] 29 | const arr3 = [-12, -15, -6, -3, -2, 0, -23, -13, -75] 30 | selectionSort(arr1) 31 | assert.deepEqual(arr1, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) 32 | selectionSort(arr2) 33 | assert.deepEqual(arr2, [-23, -1, 0, 10, 11, 34, 56, 75, 103]) 34 | selectionSort(arr3) 35 | assert.deepEqual(arr3, [-75, -23, -15, -13, -12, -6, -3, -2, 0]) 36 | }) 37 | }) 38 | }) 39 | describe('Insertion Sort', () => { 40 | describe('insert', () => { 41 | it('inserts members of an array to the right given an index', () => { 42 | const arr = [4, 3, 2, 1] 43 | insert(arr, 2, 1) 44 | assert.deepEqual(arr, [1, 4, 3, 2]) 45 | insert(arr, 2, 2) 46 | assert.deepEqual(arr, [1, 2, 4, 3]) 47 | insert(arr, 2, 3) 48 | assert.deepEqual(arr, [1, 2, 3, 4]) 49 | }) 50 | }) 51 | describe('insertionSort', () => { 52 | it('sorts an array in place', () => { 53 | const arr1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] 54 | const arr2 = [56, 34, 103, -1, 11, 0, -23, 10, 75] 55 | const arr3 = [-12, -15, -6, -3, -2, 0, -23, -13, -75] 56 | insertionSort(arr1) 57 | assert.deepEqual(arr1, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) 58 | insertionSort(arr2) 59 | assert.deepEqual(arr2, [-23, -1, 0, 10, 11, 34, 56, 75, 103]) 60 | insertionSort(arr3) 61 | assert.deepEqual(arr3, [-75, -23, -15, -13, -12, -6, -3, -2, 0]) 62 | }) 63 | }) 64 | }) 65 | describe('Merge Sort', () => { 66 | describe('merge', () => { 67 | it('merges divides an array in half given a subset and sorts them in place', () => { 68 | const arr = [4, 3, 2, 1] 69 | merge(arr, 0, 1, 3) 70 | assert.deepEqual(arr, [2, 1, 4, 3]) 71 | merge(arr, 0, 0, 1) 72 | assert.deepEqual(arr, [1, 2, 4, 3]) 73 | merge(arr, 2, 2, 3) 74 | assert.deepEqual(arr, [1, 2, 3, 4]) 75 | }) 76 | }) 77 | describe('mergeSort', () => { 78 | it('sorts an array in place', () => { 79 | const arr1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] 80 | const arr2 = [56, 34, 103, -1, 11, 0, -23, 10, 75] 81 | const arr3 = [-12, -15, -6, -3, -2, 0, -23, -13, -75] 82 | mergeSort(arr1) 83 | assert.deepEqual(arr1, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) 84 | mergeSort(arr2) 85 | assert.deepEqual(arr2, [-23, -1, 0, 10, 11, 34, 56, 75, 103]) 86 | mergeSort(arr3) 87 | assert.deepEqual(arr3, [-75, -23, -15, -13, -12, -6, -3, -2, 0]) 88 | }) 89 | }) 90 | }) 91 | describe('Quick Sort', () => { 92 | describe('swap', () => { 93 | it('swaps position of two items in an array given their indices', () => { 94 | const arr = [4, 3, 2, 1] 95 | quickSwap(arr, 0, 3) 96 | assert.deepEqual(arr, [1, 3, 2, 4]) 97 | quickSwap(arr, 1, 2) 98 | assert.deepEqual(arr, [1, 2, 3, 4]) 99 | }) 100 | }) 101 | describe('partition', () => { 102 | it('partitions the array and moves all smaller members to the left of the pivot and larger members to the right of the pivot', () => { 103 | const arr = [4, 3, 2, 1] 104 | assert.deepEqual(partition(arr, 0, 3), 0) 105 | assert.deepEqual(arr, [1, 3, 2, 4]) 106 | assert.deepEqual(partition(arr, 1, 2), 1) 107 | assert.deepEqual(arr, [1, 2, 3, 4]) 108 | }) 109 | }) 110 | describe('quickSort', () => { 111 | it('sorts an array in place', () => { 112 | const arr1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] 113 | const arr2 = [56, 34, 103, -1, 11, 0, -23, 10, 75] 114 | const arr3 = [-12, -15, -6, -3, -2, 0, -23, -13, -75] 115 | quickSort(arr1) 116 | assert.deepEqual(arr1, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) 117 | quickSort(arr2) 118 | assert.deepEqual(arr2, [-23, -1, 0, 10, 11, 34, 56, 75, 103]) 119 | quickSort(arr3) 120 | assert.deepEqual(arr3, [-75, -23, -15, -13, -12, -6, -3, -2, 0]) 121 | }) 122 | }) 123 | }) 124 | }) 125 | -------------------------------------------------------------------------------- /challenges/typescript/challenges/insertionSort.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This challenge is purposefully set up to have `insert` be solved first 3 | * */ 4 | export function insert(array: number[], rightIndex: number, value: number): void { 5 | 6 | } 7 | 8 | export function insertionSort(array: number[]): void { 9 | // how can you use insert to continuously insert values into their correct position? 10 | } 11 | -------------------------------------------------------------------------------- /challenges/typescript/challenges/mergeSort.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This challenge is purposefully set up to have `merge` be solved first 3 | * code commented out with // is meant to be used as an aide. 4 | * if you dont want it simply delete the lines and try for yourself! 5 | * you can use this regex to delete all those lines /\/\/.+/ with a find and replace in your editor 6 | * */ 7 | export function merge(array: number[], lowHalfBegin: number, boundary: number, highHalfEnd: number): void { 8 | const lowHalf: number[] = [] 9 | const highHalf: number[] = [] 10 | 11 | let cursor = lowHalfBegin 12 | // divide the content of the array into two new temporary arrays, lowHalf and highHalf 13 | 14 | /** 15 | * Repeatedly compare the lowest untaken element in 16 | * lowHalf with the lowest untaken element in highHalf 17 | * and copy the lower of the two back into array 18 | */ 19 | cursor = lowHalfBegin 20 | let lowHalfCursor = 0 21 | let highHalfCursor = 0 22 | // while (lowHalfCursor < lowHalf.length && highHalfCursor < highHalf.length) { 23 | 24 | // } 25 | /** 26 | * Once one of lowHalf and highHalf has been fully copied 27 | * back into array, copy the remaining elements from the 28 | * other temporary array back into the array 29 | */ 30 | // while (lowHalfCursor < lowHalf.length) { 31 | 32 | // } 33 | // while (highHalfCursor < highHalf.length) { 34 | 35 | // } 36 | } 37 | 38 | // Takes an array and recursively merge sorts it 39 | export function mergeSort(array: number[], lowHalfBegin = 0, highHalfEnd = array.length - 1): void { 40 | // if (lowHalfBegin < highHalfEnd){ 41 | 42 | // } 43 | } 44 | -------------------------------------------------------------------------------- /challenges/typescript/challenges/quickSort.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This challenge is purposefully set up to have `swap` and `partition` be solved first 3 | * code commented out with // is meant to be used as an aide. 4 | * if you dont want it simply delete the lines and try for yourself! 5 | * you can use this regex to delete all those lines /\/\/.+/ with a find and replace in your editor 6 | * */ 7 | 8 | /** 9 | * Swaps two items in an array, changing the original array 10 | */ 11 | export function swap(array: number[], firstIndex: number, secondIndex: number): void { 12 | 13 | } 14 | /** 15 | * This function partitions given array and returns the index of the pivot. 16 | */ 17 | export function partition(array, left, right): number { 18 | let pivotPosition = left 19 | 20 | /** 21 | * Compare array[nextToCompare] with array[right], for nextToCompare = left, left + 1,... right - 1 22 | * maintaining that: 23 | * array[right] (last element) is the pivot 24 | * array[left..pivotPosition-1] are values known to be <= to array[right] 25 | * i.e. Values to left of pivot are less than or equal to pivot 26 | * array[pivotPosition..nextToCompare - 1] are values known to be > array[right] 27 | * i.e. Values to right of pivot are greater than pivot 28 | * array[nextToCompare..right - 1] haven't been compared with array[right] 29 | * If array[nextToCompare] > array[right], just increment nextToCompare. 30 | */ 31 | // for (let nextToCompare = left; nextToCompare < right; nextToCompare++) { 32 | /** 33 | * If array[nextToCompare] <= array[right], swap array[nextToCompare] with array[pivotPosition], 34 | * increment pivotPosition, and increment nextToCompare. 35 | */ 36 | 37 | // } 38 | 39 | /** 40 | * Once all elements in array[left..right-1] 41 | * have been compared with array[right], 42 | * swap array[right] with array[pivotPosition], and return pivotPosition. 43 | */ 44 | 45 | /** 46 | * pivotPosition is the new index of the pivot 47 | */ 48 | } 49 | 50 | /** 51 | * Recursively find the pivot and quickSort your array, dividing each array as you recurse 52 | */ 53 | export function quickSort(array: number[], left: number = 0, right: number = array.length - 1): void { 54 | 55 | } 56 | -------------------------------------------------------------------------------- /challenges/typescript/challenges/selectionSort.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This challenge is purposefully set up to have `swap` and `indexOfMinimum` be solved first 3 | * */ 4 | export function swap(array: number[], firstIndex: number, secondIndex: number): void { 5 | 6 | } 7 | 8 | export function indexOfMinimum(array: number[], startIndex: number): number { 9 | 10 | } 11 | 12 | export function selectionSort(array: number[]): void { 13 | // how can you use `swap` and `indexOfMinimum` to continually sort the array? 14 | } 15 | -------------------------------------------------------------------------------- /challenges/typescript/mocha.opts: -------------------------------------------------------------------------------- 1 | --bail 2 | --require ts-node/register 3 | challenges/*.test.ts 4 | -------------------------------------------------------------------------------- /challenges/typescript/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tech-interview-cheat-sheet-challenges", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/chai": { 8 | "version": "4.2.7", 9 | "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.7.tgz", 10 | "integrity": "sha512-luq8meHGYwvky0O7u0eQZdA7B4Wd9owUCqvbw2m3XCrCU8mplYOujMBbvyS547AxJkC+pGnd0Cm15eNxEUNU8g==", 11 | "dev": true 12 | }, 13 | "@types/mocha": { 14 | "version": "5.2.7", 15 | "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.7.tgz", 16 | "integrity": "sha512-NYrtPht0wGzhwe9+/idPaBB+TqkY9AhTvOLMkThm0IoEfLaiVQZwBwyJ5puCkO3AUCWrmcoePjp2mbFocKy4SQ==", 17 | "dev": true 18 | }, 19 | "ansi-colors": { 20 | "version": "3.2.3", 21 | "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", 22 | "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==", 23 | "dev": true 24 | }, 25 | "ansi-regex": { 26 | "version": "3.0.0", 27 | "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", 28 | "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", 29 | "dev": true 30 | }, 31 | "ansi-styles": { 32 | "version": "3.2.1", 33 | "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", 34 | "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", 35 | "dev": true, 36 | "requires": { 37 | "color-convert": "^1.9.0" 38 | } 39 | }, 40 | "anymatch": { 41 | "version": "3.1.1", 42 | "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.1.tgz", 43 | "integrity": "sha512-mM8522psRCqzV+6LhomX5wgp25YVibjh8Wj23I5RPkPppSVSjyKD2A2mBJmWGa+KN7f2D6LNh9jkBCeyLktzjg==", 44 | "dev": true, 45 | "requires": { 46 | "normalize-path": "^3.0.0", 47 | "picomatch": "^2.0.4" 48 | } 49 | }, 50 | "arg": { 51 | "version": "4.1.2", 52 | "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.2.tgz", 53 | "integrity": "sha512-+ytCkGcBtHZ3V2r2Z06AncYO8jz46UEamcspGoU8lHcEbpn6J77QK0vdWvChsclg/tM5XIJC5tnjmPp7Eq6Obg==", 54 | "dev": true 55 | }, 56 | "argparse": { 57 | "version": "1.0.10", 58 | "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", 59 | "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", 60 | "dev": true, 61 | "requires": { 62 | "sprintf-js": "~1.0.2" 63 | } 64 | }, 65 | "assertion-error": { 66 | "version": "1.1.0", 67 | "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", 68 | "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", 69 | "dev": true 70 | }, 71 | "balanced-match": { 72 | "version": "1.0.0", 73 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 74 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", 75 | "dev": true 76 | }, 77 | "binary-extensions": { 78 | "version": "2.0.0", 79 | "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.0.0.tgz", 80 | "integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==", 81 | "dev": true 82 | }, 83 | "brace-expansion": { 84 | "version": "1.1.11", 85 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 86 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 87 | "dev": true, 88 | "requires": { 89 | "balanced-match": "^1.0.0", 90 | "concat-map": "0.0.1" 91 | } 92 | }, 93 | "braces": { 94 | "version": "3.0.2", 95 | "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", 96 | "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", 97 | "dev": true, 98 | "requires": { 99 | "fill-range": "^7.0.1" 100 | } 101 | }, 102 | "browser-stdout": { 103 | "version": "1.3.1", 104 | "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", 105 | "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", 106 | "dev": true 107 | }, 108 | "buffer-from": { 109 | "version": "1.1.1", 110 | "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", 111 | "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", 112 | "dev": true 113 | }, 114 | "camelcase": { 115 | "version": "5.3.1", 116 | "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", 117 | "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", 118 | "dev": true 119 | }, 120 | "chai": { 121 | "version": "4.2.0", 122 | "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", 123 | "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", 124 | "dev": true, 125 | "requires": { 126 | "assertion-error": "^1.1.0", 127 | "check-error": "^1.0.2", 128 | "deep-eql": "^3.0.1", 129 | "get-func-name": "^2.0.0", 130 | "pathval": "^1.1.0", 131 | "type-detect": "^4.0.5" 132 | } 133 | }, 134 | "chalk": { 135 | "version": "2.4.2", 136 | "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", 137 | "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", 138 | "dev": true, 139 | "requires": { 140 | "ansi-styles": "^3.2.1", 141 | "escape-string-regexp": "^1.0.5", 142 | "supports-color": "^5.3.0" 143 | }, 144 | "dependencies": { 145 | "supports-color": { 146 | "version": "5.5.0", 147 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", 148 | "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", 149 | "dev": true, 150 | "requires": { 151 | "has-flag": "^3.0.0" 152 | } 153 | } 154 | } 155 | }, 156 | "check-error": { 157 | "version": "1.0.2", 158 | "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", 159 | "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", 160 | "dev": true 161 | }, 162 | "chokidar": { 163 | "version": "3.3.0", 164 | "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.3.0.tgz", 165 | "integrity": "sha512-dGmKLDdT3Gdl7fBUe8XK+gAtGmzy5Fn0XkkWQuYxGIgWVPPse2CxFA5mtrlD0TOHaHjEUqkWNyP1XdHoJES/4A==", 166 | "dev": true, 167 | "requires": { 168 | "anymatch": "~3.1.1", 169 | "braces": "~3.0.2", 170 | "fsevents": "~2.1.1", 171 | "glob-parent": "~5.1.0", 172 | "is-binary-path": "~2.1.0", 173 | "is-glob": "~4.0.1", 174 | "normalize-path": "~3.0.0", 175 | "readdirp": "~3.2.0" 176 | } 177 | }, 178 | "cliui": { 179 | "version": "5.0.0", 180 | "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", 181 | "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", 182 | "dev": true, 183 | "requires": { 184 | "string-width": "^3.1.0", 185 | "strip-ansi": "^5.2.0", 186 | "wrap-ansi": "^5.1.0" 187 | }, 188 | "dependencies": { 189 | "ansi-regex": { 190 | "version": "4.1.0", 191 | "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", 192 | "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", 193 | "dev": true 194 | }, 195 | "string-width": { 196 | "version": "3.1.0", 197 | "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", 198 | "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", 199 | "dev": true, 200 | "requires": { 201 | "emoji-regex": "^7.0.1", 202 | "is-fullwidth-code-point": "^2.0.0", 203 | "strip-ansi": "^5.1.0" 204 | } 205 | }, 206 | "strip-ansi": { 207 | "version": "5.2.0", 208 | "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", 209 | "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", 210 | "dev": true, 211 | "requires": { 212 | "ansi-regex": "^4.1.0" 213 | } 214 | } 215 | } 216 | }, 217 | "color-convert": { 218 | "version": "1.9.3", 219 | "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", 220 | "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", 221 | "dev": true, 222 | "requires": { 223 | "color-name": "1.1.3" 224 | } 225 | }, 226 | "color-name": { 227 | "version": "1.1.3", 228 | "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", 229 | "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", 230 | "dev": true 231 | }, 232 | "concat-map": { 233 | "version": "0.0.1", 234 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 235 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", 236 | "dev": true 237 | }, 238 | "debug": { 239 | "version": "3.2.6", 240 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", 241 | "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", 242 | "dev": true, 243 | "requires": { 244 | "ms": "^2.1.1" 245 | } 246 | }, 247 | "decamelize": { 248 | "version": "1.2.0", 249 | "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", 250 | "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", 251 | "dev": true 252 | }, 253 | "deep-eql": { 254 | "version": "3.0.1", 255 | "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", 256 | "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", 257 | "dev": true, 258 | "requires": { 259 | "type-detect": "^4.0.0" 260 | } 261 | }, 262 | "define-properties": { 263 | "version": "1.1.3", 264 | "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", 265 | "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", 266 | "dev": true, 267 | "requires": { 268 | "object-keys": "^1.0.12" 269 | } 270 | }, 271 | "diff": { 272 | "version": "3.5.0", 273 | "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", 274 | "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", 275 | "dev": true 276 | }, 277 | "emoji-regex": { 278 | "version": "7.0.3", 279 | "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", 280 | "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", 281 | "dev": true 282 | }, 283 | "es-abstract": { 284 | "version": "1.17.0", 285 | "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.0.tgz", 286 | "integrity": "sha512-yYkE07YF+6SIBmg1MsJ9dlub5L48Ek7X0qz+c/CPCHS9EBXfESorzng4cJQjJW5/pB6vDF41u7F8vUhLVDqIug==", 287 | "dev": true, 288 | "requires": { 289 | "es-to-primitive": "^1.2.1", 290 | "function-bind": "^1.1.1", 291 | "has": "^1.0.3", 292 | "has-symbols": "^1.0.1", 293 | "is-callable": "^1.1.5", 294 | "is-regex": "^1.0.5", 295 | "object-inspect": "^1.7.0", 296 | "object-keys": "^1.1.1", 297 | "object.assign": "^4.1.0", 298 | "string.prototype.trimleft": "^2.1.1", 299 | "string.prototype.trimright": "^2.1.1" 300 | } 301 | }, 302 | "es-to-primitive": { 303 | "version": "1.2.1", 304 | "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", 305 | "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", 306 | "dev": true, 307 | "requires": { 308 | "is-callable": "^1.1.4", 309 | "is-date-object": "^1.0.1", 310 | "is-symbol": "^1.0.2" 311 | } 312 | }, 313 | "escape-string-regexp": { 314 | "version": "1.0.5", 315 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", 316 | "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", 317 | "dev": true 318 | }, 319 | "esprima": { 320 | "version": "4.0.1", 321 | "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", 322 | "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", 323 | "dev": true 324 | }, 325 | "fill-range": { 326 | "version": "7.0.1", 327 | "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", 328 | "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", 329 | "dev": true, 330 | "requires": { 331 | "to-regex-range": "^5.0.1" 332 | } 333 | }, 334 | "find-up": { 335 | "version": "3.0.0", 336 | "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", 337 | "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", 338 | "dev": true, 339 | "requires": { 340 | "locate-path": "^3.0.0" 341 | } 342 | }, 343 | "flat": { 344 | "version": "4.1.0", 345 | "resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz", 346 | "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==", 347 | "dev": true, 348 | "requires": { 349 | "is-buffer": "~2.0.3" 350 | } 351 | }, 352 | "fs.realpath": { 353 | "version": "1.0.0", 354 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 355 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", 356 | "dev": true 357 | }, 358 | "fsevents": { 359 | "version": "2.1.2", 360 | "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.1.2.tgz", 361 | "integrity": "sha512-R4wDiBwZ0KzpgOWetKDug1FZcYhqYnUYKtfZYt4mD5SBz76q0KR4Q9o7GIPamsVPGmW3EYPPJ0dOOjvx32ldZA==", 362 | "dev": true, 363 | "optional": true 364 | }, 365 | "function-bind": { 366 | "version": "1.1.1", 367 | "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", 368 | "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", 369 | "dev": true 370 | }, 371 | "get-caller-file": { 372 | "version": "2.0.5", 373 | "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", 374 | "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", 375 | "dev": true 376 | }, 377 | "get-func-name": { 378 | "version": "2.0.0", 379 | "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", 380 | "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", 381 | "dev": true 382 | }, 383 | "glob": { 384 | "version": "7.1.3", 385 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", 386 | "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", 387 | "dev": true, 388 | "requires": { 389 | "fs.realpath": "^1.0.0", 390 | "inflight": "^1.0.4", 391 | "inherits": "2", 392 | "minimatch": "^3.0.4", 393 | "once": "^1.3.0", 394 | "path-is-absolute": "^1.0.0" 395 | } 396 | }, 397 | "glob-parent": { 398 | "version": "5.1.0", 399 | "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", 400 | "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", 401 | "dev": true, 402 | "requires": { 403 | "is-glob": "^4.0.1" 404 | } 405 | }, 406 | "growl": { 407 | "version": "1.10.5", 408 | "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", 409 | "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", 410 | "dev": true 411 | }, 412 | "has": { 413 | "version": "1.0.3", 414 | "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", 415 | "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", 416 | "dev": true, 417 | "requires": { 418 | "function-bind": "^1.1.1" 419 | } 420 | }, 421 | "has-flag": { 422 | "version": "3.0.0", 423 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", 424 | "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", 425 | "dev": true 426 | }, 427 | "has-symbols": { 428 | "version": "1.0.1", 429 | "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", 430 | "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", 431 | "dev": true 432 | }, 433 | "he": { 434 | "version": "1.2.0", 435 | "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", 436 | "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", 437 | "dev": true 438 | }, 439 | "inflight": { 440 | "version": "1.0.6", 441 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 442 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 443 | "dev": true, 444 | "requires": { 445 | "once": "^1.3.0", 446 | "wrappy": "1" 447 | } 448 | }, 449 | "inherits": { 450 | "version": "2.0.4", 451 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 452 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", 453 | "dev": true 454 | }, 455 | "is-binary-path": { 456 | "version": "2.1.0", 457 | "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", 458 | "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", 459 | "dev": true, 460 | "requires": { 461 | "binary-extensions": "^2.0.0" 462 | } 463 | }, 464 | "is-buffer": { 465 | "version": "2.0.4", 466 | "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", 467 | "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==", 468 | "dev": true 469 | }, 470 | "is-callable": { 471 | "version": "1.1.5", 472 | "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", 473 | "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==", 474 | "dev": true 475 | }, 476 | "is-date-object": { 477 | "version": "1.0.2", 478 | "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", 479 | "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", 480 | "dev": true 481 | }, 482 | "is-extglob": { 483 | "version": "2.1.1", 484 | "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", 485 | "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", 486 | "dev": true 487 | }, 488 | "is-fullwidth-code-point": { 489 | "version": "2.0.0", 490 | "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", 491 | "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", 492 | "dev": true 493 | }, 494 | "is-glob": { 495 | "version": "4.0.1", 496 | "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", 497 | "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", 498 | "dev": true, 499 | "requires": { 500 | "is-extglob": "^2.1.1" 501 | } 502 | }, 503 | "is-number": { 504 | "version": "7.0.0", 505 | "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", 506 | "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", 507 | "dev": true 508 | }, 509 | "is-regex": { 510 | "version": "1.0.5", 511 | "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", 512 | "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", 513 | "dev": true, 514 | "requires": { 515 | "has": "^1.0.3" 516 | } 517 | }, 518 | "is-symbol": { 519 | "version": "1.0.3", 520 | "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", 521 | "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", 522 | "dev": true, 523 | "requires": { 524 | "has-symbols": "^1.0.1" 525 | } 526 | }, 527 | "isexe": { 528 | "version": "2.0.0", 529 | "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", 530 | "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", 531 | "dev": true 532 | }, 533 | "js-yaml": { 534 | "version": "3.13.1", 535 | "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", 536 | "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", 537 | "dev": true, 538 | "requires": { 539 | "argparse": "^1.0.7", 540 | "esprima": "^4.0.0" 541 | } 542 | }, 543 | "locate-path": { 544 | "version": "3.0.0", 545 | "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", 546 | "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", 547 | "dev": true, 548 | "requires": { 549 | "p-locate": "^3.0.0", 550 | "path-exists": "^3.0.0" 551 | } 552 | }, 553 | "lodash": { 554 | "version": "4.17.15", 555 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", 556 | "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", 557 | "dev": true 558 | }, 559 | "log-symbols": { 560 | "version": "2.2.0", 561 | "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", 562 | "integrity": "sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg==", 563 | "dev": true, 564 | "requires": { 565 | "chalk": "^2.0.1" 566 | } 567 | }, 568 | "make-error": { 569 | "version": "1.3.5", 570 | "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz", 571 | "integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==", 572 | "dev": true 573 | }, 574 | "minimatch": { 575 | "version": "3.0.4", 576 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 577 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 578 | "dev": true, 579 | "requires": { 580 | "brace-expansion": "^1.1.7" 581 | } 582 | }, 583 | "minimist": { 584 | "version": "0.0.8", 585 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", 586 | "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", 587 | "dev": true 588 | }, 589 | "mkdirp": { 590 | "version": "0.5.1", 591 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", 592 | "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", 593 | "dev": true, 594 | "requires": { 595 | "minimist": "0.0.8" 596 | } 597 | }, 598 | "mocha": { 599 | "version": "7.0.0", 600 | "resolved": "https://registry.npmjs.org/mocha/-/mocha-7.0.0.tgz", 601 | "integrity": "sha512-CirsOPbO3jU86YKjjMzFLcXIb5YiGLUrjrXFHoJ3e2z9vWiaZVCZQ2+gtRGMPWF+nFhN6AWwLM/juzAQ6KRkbA==", 602 | "dev": true, 603 | "requires": { 604 | "ansi-colors": "3.2.3", 605 | "browser-stdout": "1.3.1", 606 | "chokidar": "3.3.0", 607 | "debug": "3.2.6", 608 | "diff": "3.5.0", 609 | "escape-string-regexp": "1.0.5", 610 | "find-up": "3.0.0", 611 | "glob": "7.1.3", 612 | "growl": "1.10.5", 613 | "he": "1.2.0", 614 | "js-yaml": "3.13.1", 615 | "log-symbols": "2.2.0", 616 | "minimatch": "3.0.4", 617 | "mkdirp": "0.5.1", 618 | "ms": "2.1.1", 619 | "node-environment-flags": "1.0.6", 620 | "object.assign": "4.1.0", 621 | "strip-json-comments": "2.0.1", 622 | "supports-color": "6.0.0", 623 | "which": "1.3.1", 624 | "wide-align": "1.1.3", 625 | "yargs": "13.3.0", 626 | "yargs-parser": "13.1.1", 627 | "yargs-unparser": "1.6.0" 628 | } 629 | }, 630 | "ms": { 631 | "version": "2.1.1", 632 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", 633 | "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", 634 | "dev": true 635 | }, 636 | "node-environment-flags": { 637 | "version": "1.0.6", 638 | "resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.6.tgz", 639 | "integrity": "sha512-5Evy2epuL+6TM0lCQGpFIj6KwiEsGh1SrHUhTbNX+sLbBtjidPZFAnVK9y5yU1+h//RitLbRHTIMyxQPtxMdHw==", 640 | "dev": true, 641 | "requires": { 642 | "object.getownpropertydescriptors": "^2.0.3", 643 | "semver": "^5.7.0" 644 | } 645 | }, 646 | "normalize-path": { 647 | "version": "3.0.0", 648 | "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", 649 | "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", 650 | "dev": true 651 | }, 652 | "object-inspect": { 653 | "version": "1.7.0", 654 | "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", 655 | "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", 656 | "dev": true 657 | }, 658 | "object-keys": { 659 | "version": "1.1.1", 660 | "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", 661 | "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", 662 | "dev": true 663 | }, 664 | "object.assign": { 665 | "version": "4.1.0", 666 | "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", 667 | "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", 668 | "dev": true, 669 | "requires": { 670 | "define-properties": "^1.1.2", 671 | "function-bind": "^1.1.1", 672 | "has-symbols": "^1.0.0", 673 | "object-keys": "^1.0.11" 674 | } 675 | }, 676 | "object.getownpropertydescriptors": { 677 | "version": "2.1.0", 678 | "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.0.tgz", 679 | "integrity": "sha512-Z53Oah9A3TdLoblT7VKJaTDdXdT+lQO+cNpKVnya5JDe9uLvzu1YyY1yFDFrcxrlRgWrEFH0jJtD/IbuwjcEVg==", 680 | "dev": true, 681 | "requires": { 682 | "define-properties": "^1.1.3", 683 | "es-abstract": "^1.17.0-next.1" 684 | } 685 | }, 686 | "once": { 687 | "version": "1.4.0", 688 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 689 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 690 | "dev": true, 691 | "requires": { 692 | "wrappy": "1" 693 | } 694 | }, 695 | "p-limit": { 696 | "version": "2.2.2", 697 | "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.2.tgz", 698 | "integrity": "sha512-WGR+xHecKTr7EbUEhyLSh5Dube9JtdiG78ufaeLxTgpudf/20KqyMioIUZJAezlTIi6evxuoUs9YXc11cU+yzQ==", 699 | "dev": true, 700 | "requires": { 701 | "p-try": "^2.0.0" 702 | } 703 | }, 704 | "p-locate": { 705 | "version": "3.0.0", 706 | "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", 707 | "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", 708 | "dev": true, 709 | "requires": { 710 | "p-limit": "^2.0.0" 711 | } 712 | }, 713 | "p-try": { 714 | "version": "2.2.0", 715 | "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", 716 | "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", 717 | "dev": true 718 | }, 719 | "path-exists": { 720 | "version": "3.0.0", 721 | "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", 722 | "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", 723 | "dev": true 724 | }, 725 | "path-is-absolute": { 726 | "version": "1.0.1", 727 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 728 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", 729 | "dev": true 730 | }, 731 | "pathval": { 732 | "version": "1.1.0", 733 | "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", 734 | "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", 735 | "dev": true 736 | }, 737 | "picomatch": { 738 | "version": "2.2.1", 739 | "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.1.tgz", 740 | "integrity": "sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA==", 741 | "dev": true 742 | }, 743 | "readdirp": { 744 | "version": "3.2.0", 745 | "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.2.0.tgz", 746 | "integrity": "sha512-crk4Qu3pmXwgxdSgGhgA/eXiJAPQiX4GMOZZMXnqKxHX7TaoL+3gQVo/WeuAiogr07DpnfjIMpXXa+PAIvwPGQ==", 747 | "dev": true, 748 | "requires": { 749 | "picomatch": "^2.0.4" 750 | } 751 | }, 752 | "require-directory": { 753 | "version": "2.1.1", 754 | "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", 755 | "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", 756 | "dev": true 757 | }, 758 | "require-main-filename": { 759 | "version": "2.0.0", 760 | "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", 761 | "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", 762 | "dev": true 763 | }, 764 | "semver": { 765 | "version": "5.7.1", 766 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", 767 | "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", 768 | "dev": true 769 | }, 770 | "set-blocking": { 771 | "version": "2.0.0", 772 | "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", 773 | "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", 774 | "dev": true 775 | }, 776 | "source-map": { 777 | "version": "0.6.1", 778 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", 779 | "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", 780 | "dev": true 781 | }, 782 | "source-map-support": { 783 | "version": "0.5.16", 784 | "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.16.tgz", 785 | "integrity": "sha512-efyLRJDr68D9hBBNIPWFjhpFzURh+KJykQwvMyW5UiZzYwoF6l4YMMDIJJEyFWxWCqfyxLzz6tSfUFR+kXXsVQ==", 786 | "dev": true, 787 | "requires": { 788 | "buffer-from": "^1.0.0", 789 | "source-map": "^0.6.0" 790 | } 791 | }, 792 | "sprintf-js": { 793 | "version": "1.0.3", 794 | "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", 795 | "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", 796 | "dev": true 797 | }, 798 | "string-width": { 799 | "version": "2.1.1", 800 | "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", 801 | "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", 802 | "dev": true, 803 | "requires": { 804 | "is-fullwidth-code-point": "^2.0.0", 805 | "strip-ansi": "^4.0.0" 806 | } 807 | }, 808 | "string.prototype.trimleft": { 809 | "version": "2.1.1", 810 | "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.1.tgz", 811 | "integrity": "sha512-iu2AGd3PuP5Rp7x2kEZCrB2Nf41ehzh+goo8TV7z8/XDBbsvc6HQIlUl9RjkZ4oyrW1XM5UwlGl1oVEaDjg6Ag==", 812 | "dev": true, 813 | "requires": { 814 | "define-properties": "^1.1.3", 815 | "function-bind": "^1.1.1" 816 | } 817 | }, 818 | "string.prototype.trimright": { 819 | "version": "2.1.1", 820 | "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.1.tgz", 821 | "integrity": "sha512-qFvWL3/+QIgZXVmJBfpHmxLB7xsUXz6HsUmP8+5dRaC3Q7oKUv9Vo6aMCRZC1smrtyECFsIT30PqBJ1gTjAs+g==", 822 | "dev": true, 823 | "requires": { 824 | "define-properties": "^1.1.3", 825 | "function-bind": "^1.1.1" 826 | } 827 | }, 828 | "strip-ansi": { 829 | "version": "4.0.0", 830 | "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", 831 | "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", 832 | "dev": true, 833 | "requires": { 834 | "ansi-regex": "^3.0.0" 835 | } 836 | }, 837 | "strip-json-comments": { 838 | "version": "2.0.1", 839 | "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", 840 | "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", 841 | "dev": true 842 | }, 843 | "supports-color": { 844 | "version": "6.0.0", 845 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", 846 | "integrity": "sha512-on9Kwidc1IUQo+bQdhi8+Tijpo0e1SS6RoGo2guUwn5vdaxw8RXOF9Vb2ws+ihWOmh4JnCJOvaziZWP1VABaLg==", 847 | "dev": true, 848 | "requires": { 849 | "has-flag": "^3.0.0" 850 | } 851 | }, 852 | "to-regex-range": { 853 | "version": "5.0.1", 854 | "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", 855 | "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", 856 | "dev": true, 857 | "requires": { 858 | "is-number": "^7.0.0" 859 | } 860 | }, 861 | "ts-node": { 862 | "version": "8.6.2", 863 | "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.6.2.tgz", 864 | "integrity": "sha512-4mZEbofxGqLL2RImpe3zMJukvEvcO1XP8bj8ozBPySdCUXEcU5cIRwR0aM3R+VoZq7iXc8N86NC0FspGRqP4gg==", 865 | "dev": true, 866 | "requires": { 867 | "arg": "^4.1.0", 868 | "diff": "^4.0.1", 869 | "make-error": "^1.1.1", 870 | "source-map-support": "^0.5.6", 871 | "yn": "3.1.1" 872 | }, 873 | "dependencies": { 874 | "diff": { 875 | "version": "4.0.2", 876 | "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", 877 | "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", 878 | "dev": true 879 | } 880 | } 881 | }, 882 | "type-detect": { 883 | "version": "4.0.8", 884 | "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", 885 | "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", 886 | "dev": true 887 | }, 888 | "typescript": { 889 | "version": "3.7.4", 890 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.4.tgz", 891 | "integrity": "sha512-A25xv5XCtarLwXpcDNZzCGvW2D1S3/bACratYBx2sax8PefsFhlYmkQicKHvpYflFS8if4zne5zT5kpJ7pzuvw==", 892 | "dev": true 893 | }, 894 | "which": { 895 | "version": "1.3.1", 896 | "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", 897 | "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", 898 | "dev": true, 899 | "requires": { 900 | "isexe": "^2.0.0" 901 | } 902 | }, 903 | "which-module": { 904 | "version": "2.0.0", 905 | "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", 906 | "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", 907 | "dev": true 908 | }, 909 | "wide-align": { 910 | "version": "1.1.3", 911 | "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", 912 | "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", 913 | "dev": true, 914 | "requires": { 915 | "string-width": "^1.0.2 || 2" 916 | } 917 | }, 918 | "wrap-ansi": { 919 | "version": "5.1.0", 920 | "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", 921 | "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", 922 | "dev": true, 923 | "requires": { 924 | "ansi-styles": "^3.2.0", 925 | "string-width": "^3.0.0", 926 | "strip-ansi": "^5.0.0" 927 | }, 928 | "dependencies": { 929 | "ansi-regex": { 930 | "version": "4.1.0", 931 | "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", 932 | "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", 933 | "dev": true 934 | }, 935 | "string-width": { 936 | "version": "3.1.0", 937 | "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", 938 | "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", 939 | "dev": true, 940 | "requires": { 941 | "emoji-regex": "^7.0.1", 942 | "is-fullwidth-code-point": "^2.0.0", 943 | "strip-ansi": "^5.1.0" 944 | } 945 | }, 946 | "strip-ansi": { 947 | "version": "5.2.0", 948 | "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", 949 | "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", 950 | "dev": true, 951 | "requires": { 952 | "ansi-regex": "^4.1.0" 953 | } 954 | } 955 | } 956 | }, 957 | "wrappy": { 958 | "version": "1.0.2", 959 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 960 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", 961 | "dev": true 962 | }, 963 | "y18n": { 964 | "version": "4.0.0", 965 | "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", 966 | "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", 967 | "dev": true 968 | }, 969 | "yargs": { 970 | "version": "13.3.0", 971 | "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz", 972 | "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==", 973 | "dev": true, 974 | "requires": { 975 | "cliui": "^5.0.0", 976 | "find-up": "^3.0.0", 977 | "get-caller-file": "^2.0.1", 978 | "require-directory": "^2.1.1", 979 | "require-main-filename": "^2.0.0", 980 | "set-blocking": "^2.0.0", 981 | "string-width": "^3.0.0", 982 | "which-module": "^2.0.0", 983 | "y18n": "^4.0.0", 984 | "yargs-parser": "^13.1.1" 985 | }, 986 | "dependencies": { 987 | "ansi-regex": { 988 | "version": "4.1.0", 989 | "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", 990 | "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", 991 | "dev": true 992 | }, 993 | "string-width": { 994 | "version": "3.1.0", 995 | "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", 996 | "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", 997 | "dev": true, 998 | "requires": { 999 | "emoji-regex": "^7.0.1", 1000 | "is-fullwidth-code-point": "^2.0.0", 1001 | "strip-ansi": "^5.1.0" 1002 | } 1003 | }, 1004 | "strip-ansi": { 1005 | "version": "5.2.0", 1006 | "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", 1007 | "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", 1008 | "dev": true, 1009 | "requires": { 1010 | "ansi-regex": "^4.1.0" 1011 | } 1012 | } 1013 | } 1014 | }, 1015 | "yargs-parser": { 1016 | "version": "13.1.1", 1017 | "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", 1018 | "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", 1019 | "dev": true, 1020 | "requires": { 1021 | "camelcase": "^5.0.0", 1022 | "decamelize": "^1.2.0" 1023 | } 1024 | }, 1025 | "yargs-unparser": { 1026 | "version": "1.6.0", 1027 | "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-1.6.0.tgz", 1028 | "integrity": "sha512-W9tKgmSn0DpSatfri0nx52Joq5hVXgeLiqR/5G0sZNDoLZFOr/xjBUDcShCOGNsBnEMNo1KAMBkTej1Hm62HTw==", 1029 | "dev": true, 1030 | "requires": { 1031 | "flat": "^4.1.0", 1032 | "lodash": "^4.17.15", 1033 | "yargs": "^13.3.0" 1034 | } 1035 | }, 1036 | "yn": { 1037 | "version": "3.1.1", 1038 | "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", 1039 | "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", 1040 | "dev": true 1041 | } 1042 | } 1043 | } 1044 | -------------------------------------------------------------------------------- /challenges/typescript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tech-interview-cheat-sheet-challenges", 3 | "version": "1.0.0", 4 | "description": "Various coding challenges for practice with passing examples", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "TS_NODE_TRANSPILE_ONLY=true mocha --opts='./mocha.opts'" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/TSiege/Tech-Interview-Cheat-Sheet.git" 12 | }, 13 | "author": "Tristan Siegel", 14 | "license": "ISC", 15 | "bugs": { 16 | "url": "https://github.com/TSiege/Tech-Interview-Cheat-Sheet/issues" 17 | }, 18 | "homepage": "https://github.com/TSiege/Tech-Interview-Cheat-Sheet#readme", 19 | "devDependencies": { 20 | "@types/chai": "^4.2.7", 21 | "@types/mocha": "^5.2.7", 22 | "chai": "^4.2.0", 23 | "mocha": "^7.0.0", 24 | "ts-node": "^8.6.2", 25 | "typescript": "^3.7.4" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /challenges/typescript/solutions/insertionSort.ts: -------------------------------------------------------------------------------- 1 | export function insert(array: number[], rightIndex: number, value: number): void { 2 | let cursor = rightIndex 3 | for(cursor; cursor >= 0 && array[cursor] > value; cursor--) { 4 | array[cursor + 1] = array[cursor] 5 | } 6 | array[cursor + 1] = value 7 | } 8 | 9 | export function insertionSort(array: number[]): void { 10 | for (let i = 1; i < array.length; i++) { 11 | insert(array, i - 1, array[i]) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /challenges/typescript/solutions/mergeSort.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This challenge is purposefully set up to have `merge` be solved first 3 | * */ 4 | export function merge(array: number[], lowHalfBegin: number, boundary: number, highHalfEnd: number): void { 5 | const lowHalf: number[] = [] 6 | const highHalf: number[] = [] 7 | 8 | let cursor = lowHalfBegin 9 | // divide the content of the array into two new temporary arrays, lowHalf and highHalf 10 | for (let i = 0; cursor <= boundary; i++, cursor++) { 11 | lowHalf[i] = array[cursor] 12 | } 13 | for (let i = 0; cursor <= highHalfEnd; i++, cursor++) { 14 | highHalf[i] = array[cursor] 15 | } 16 | /** 17 | * Repeatedly compare the lowest untaken element in 18 | * lowHalf with the lowest untaken element in highHalf 19 | * and copy the lower of the two back into array 20 | */ 21 | cursor = lowHalfBegin 22 | let lowHalfCursor = 0 23 | let highHalfCursor = 0 24 | while (lowHalfCursor < lowHalf.length && highHalfCursor < highHalf.length) { 25 | if (lowHalf[lowHalfCursor] < highHalf[highHalfCursor]) { 26 | array[cursor] = lowHalf[lowHalfCursor] 27 | lowHalfCursor++ 28 | } else { 29 | array[cursor] = highHalf[highHalfCursor] 30 | highHalfCursor++ 31 | } 32 | cursor++ 33 | } 34 | /** 35 | * Once one of lowHalf and highHalf has been fully copied 36 | * back into array, copy the remaining elements from the 37 | * other temporary array back into the array 38 | */ 39 | while (lowHalfCursor < lowHalf.length) { 40 | array[cursor] = lowHalf[lowHalfCursor] 41 | cursor++ 42 | lowHalfCursor++ 43 | } 44 | while (highHalfCursor < highHalf.length) { 45 | array[cursor] = highHalf[highHalfCursor] 46 | cursor++ 47 | highHalfCursor++ 48 | } 49 | } 50 | 51 | 52 | // Takes in an array and recursively merge sorts it 53 | export function mergeSort(array: number[], lowHalfBegin = 0, highHalfEnd = array.length - 1): void { 54 | if (lowHalfBegin < highHalfEnd){ 55 | const middle = Math.floor((lowHalfBegin + highHalfEnd) / 2) 56 | mergeSort(array, lowHalfBegin, middle) 57 | mergeSort(array, middle + 1, highHalfEnd) 58 | merge(array, lowHalfBegin, middle, highHalfEnd) 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /challenges/typescript/solutions/quickSort.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Swaps two items in an array, changing the original array 3 | */ 4 | export function swap(array: number[], firstIndex: number, secondIndex: number): void { 5 | var temp = array[firstIndex]; 6 | array[firstIndex] = array[secondIndex]; 7 | array[secondIndex] = temp; 8 | } 9 | /** 10 | * This function partitions given array and returns the index of the pivot. 11 | */ 12 | export function partition(array, left, right): number { 13 | let pivotPosition = left 14 | 15 | /** 16 | * Compare array[nextToCompare] with array[right], for nextToCompare = left, left + 1,... right - 1 17 | * maintaining that: 18 | * array[right] (last element) is the pivot 19 | * array[left..pivotPosition-1] are values known to be <= to array[right] 20 | * i.e. Values to left of pivot are less than or equal to pivot 21 | * array[pivotPosition..nextToCompare - 1] are values known to be > array[right] 22 | * i.e. Values to right of pivot are greater than pivot 23 | * array[nextToCompare..right - 1] haven't been compared with array[right] 24 | * If array[nextToCompare] > array[right], just increment nextToCompare. 25 | */ 26 | for (let nextToCompare = left; nextToCompare < right; nextToCompare++) { 27 | /** 28 | * If array[nextToCompare] <= array[right], swap array[nextToCompare] with array[pivotPosition], 29 | * increment pivotPosition, and increment nextToCompare. 30 | */ 31 | if (array[nextToCompare] <= array[right]) { 32 | swap(array, nextToCompare, pivotPosition) 33 | pivotPosition++ 34 | } 35 | } 36 | 37 | /** 38 | * Once all elements in array[left..right-1] 39 | * have been compared with array[right], 40 | * swap array[right] with array[pivotPosition], and return pivotPosition. 41 | */ 42 | swap(array, right, pivotPosition) 43 | 44 | /** 45 | * pivotPosition is the new index of the pivot 46 | */ 47 | return pivotPosition 48 | } 49 | 50 | /** 51 | * Recursively find the pivot and quickSort your array, dividing each array as you recurse 52 | */ 53 | export function quickSort(array: number[], left: number = 0, right: number = array.length - 1): void { 54 | if (left < right) { 55 | const pivot = partition(array, left, right) 56 | quickSort(array, left, pivot - 1) 57 | quickSort(array, pivot + 1, right) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /challenges/typescript/solutions/selectionSort.ts: -------------------------------------------------------------------------------- 1 | export function swap(array: number[], firstIndex: number, secondIndex: number): void { 2 | const temp = array[firstIndex] 3 | array[firstIndex] = array[secondIndex] 4 | array[secondIndex] = temp 5 | } 6 | 7 | export function indexOfMinimum(array: number[], startIndex: number): number { 8 | let minValue = array[startIndex] 9 | let minIndex = startIndex 10 | 11 | for(let i = minIndex + 1; i < array.length; i++) { 12 | if(array[i] < minValue) { 13 | minIndex = i 14 | minValue = array[i] 15 | } 16 | } 17 | 18 | return minIndex 19 | } 20 | 21 | export function selectionSort(array: number[]): void { 22 | for(let i = 0; i < array.length; i++) { 23 | const smallestIndex = indexOfMinimum(array, i) 24 | if (smallestIndex !== i) { 25 | swap(array, i, smallestIndex) 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /challenges/typescript/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "noEmit": true, 4 | "allowJs": false, 5 | "target": "es2017", 6 | "moduleResolution": "node", 7 | "module": "commonjs", 8 | "noImplicitAny": false, 9 | "strictNullChecks": true, 10 | "declaration": true, 11 | "importHelpers": true 12 | }, 13 | "include": [ 14 | "challenges/*", 15 | ], 16 | "exclude": [ 17 | "node_modules" 18 | ] 19 | } 20 | --------------------------------------------------------------------------------