diff --git a/.circleci/config.yml b/.circleci/config.yml index f7c264fa..b2fcb55b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -52,7 +52,7 @@ jobs: # a collection of steps docs: docker: - - image: circleci/ruby:2.5.3-stretch-node + - image: circleci/ruby:2.7.1-buster-node environment: NOKOGIRI_USE_SYSTEM_LIBRARIES: true steps: @@ -84,7 +84,7 @@ jobs: # a collection of steps - run: name: Bundle Install.pre - needed for mathematical -> 'asciidoctor-mathematical' gem - command: sudo apt-get -qq -y install cmake bison flex libffi-dev libxml2-dev libgdk-pixbuf2.0-dev libcairo2-dev libpango1.0-dev ttf-lyx + command: sudo apt-get -qq -y install cmake bison flex libffi-dev libxml2-dev libgdk-pixbuf2.0-dev libcairo2-dev libpango1.0-dev - run: name: Bundle Install.pre - install GraphicsMagick for 'prawn-gmagick' gem diff --git a/.eslintrc.js b/.eslintrc.js index ee4a630a..404d8807 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,24 +1,35 @@ module.exports = { extends: 'airbnb-base', env: { - jest: true + jest: true, }, + plugins: ['jest'], globals: { BigInt: true, }, + + // check package.json for files to include + // files: ['src/**/*.js', 'book/interview-questions/*.js'], + rules: { // https://github.com/airbnb/javascript/issues/1089 // https://stackoverflow.com/a/35637900/684957 // allow to add properties to arguments - 'no-param-reassign': [2, { 'props': false }], + 'no-param-reassign': [2, { props: false }], // https://eslint.org/docs/rules/no-plusplus // allows unary operators ++ and -- in the afterthought (final expression) of a for loop. - 'no-plusplus': [0, { 'allowForLoopAfterthoughts': true }], + 'no-plusplus': [0, { allowForLoopAfterthoughts: true }], 'no-continue': [0], // Allow for..of 'no-restricted-syntax': [0, 'ForOfStatement'], - } + + // jest plugin + // 'jest/no-disabled-tests': 'warn', + 'jest/no-focused-tests': 'error', + 'jest/no-identical-title': 'warn', + 'jest/valid-expect': 'warn', + }, }; diff --git a/.gitignore b/.gitignore index 363ed4fe..9675ebf8 100644 --- a/.gitignore +++ b/.gitignore @@ -86,6 +86,7 @@ local.properties ###################### # Windows image file caches Thumbs.db +*Zone.Identifier # Folder config file Desktop.ini diff --git a/.vscode/settings.json b/.vscode/settings.json index 035ef5b2..c4dcc94b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,17 +1,20 @@ { + "peacock.color": "#f9e64f", "workbench.colorCustomizations": { + "activityBar.activeBackground": "#fbed80", + "activityBar.activeBorder": "#06b9a5", "activityBar.background": "#fbed80", "activityBar.foreground": "#15202b", "activityBar.inactiveForeground": "#15202b99", "activityBarBadge.background": "#06b9a5", "activityBarBadge.foreground": "#15202b", - "titleBar.activeBackground": "#f9e64f", - "titleBar.inactiveBackground": "#f9e64f99", - "titleBar.activeForeground": "#15202b", - "titleBar.inactiveForeground": "#15202b99", "statusBar.background": "#f9e64f", + "statusBar.foreground": "#15202b", "statusBarItem.hoverBackground": "#f7df1e", - "statusBar.foreground": "#15202b" + "titleBar.activeBackground": "#f9e64f", + "titleBar.activeForeground": "#15202b", + "titleBar.inactiveBackground": "#f9e64f99", + "titleBar.inactiveForeground": "#15202b99" }, - "peacock.color": "#f9e64f" + "peacock.remoteColor": "#f9e64f" } diff --git a/CHANGELOG.md b/CHANGELOG.md index eefac3b0..4e021d32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,231 @@ +## [2.7.6](https://github.com/amejiarosario/dsa.js/compare/2.7.5...2.7.6) (2021-11-30) + + +### Bug Fixes + +* **graph:** minor typo in bfs code documentation ([ccfcfe6](https://github.com/amejiarosario/dsa.js/commit/ccfcfe6f039ce3f6e289d368fbdbf67e227c168c)), closes [#110](https://github.com/amejiarosario/dsa.js/issues/110) + +## [2.7.5](https://github.com/amejiarosario/dsa.js/compare/2.7.4...2.7.5) (2021-05-24) + + +### Bug Fixes + +* **bst:** on duplicates values the same node is returned ([d350da8](https://github.com/amejiarosario/dsa.js/commit/d350da8bd2d7cf5c8f4425e863babf19cbdcbdf4)), closes [#99](https://github.com/amejiarosario/dsa.js/issues/99) + +## [2.7.4](https://github.com/amejiarosario/dsa.js/compare/2.7.3...2.7.4) (2021-01-09) + + +### Bug Fixes + +* **bst:** some typos on the code ([6b9a4e8](https://github.com/amejiarosario/dsa.js/commit/6b9a4e8c00c2082ed7d083b58f7d462e340725fe)) + +## [2.7.3](https://github.com/amejiarosario/dsa.js/compare/2.7.2...2.7.3) (2020-12-22) + + +### Bug Fixes + +* **book/bst:** better wording ([1d75301](https://github.com/amejiarosario/dsa.js/commit/1d7530199940b926467ad0dcbc3b7dbe76b77820)) +* **book/graph:** add comments for runtimes using hashset implementations ([c7c7947](https://github.com/amejiarosario/dsa.js/commit/c7c7947da33cb61a794e538dff55951318edc341)) +* **book/hashmap:** exercise example and add tests ([c137930](https://github.com/amejiarosario/dsa.js/commit/c137930a8750c0aac95bbbae931886e068371d92)) + +## [2.7.2](https://github.com/amejiarosario/dsa.js/compare/2.7.1...2.7.2) (2020-12-17) + + +### Bug Fixes + +* **book:** Rename fibonacci-dynamic-programming ([ded0a70](https://github.com/amejiarosario/dsa.js/commit/ded0a701815ce4647394e2f5e217c0d88142a92c)) + +## [2.7.1](https://github.com/amejiarosario/dsa.js/compare/2.7.0...2.7.1) (2020-12-02) + + +### Bug Fixes + +* **book:** update company names ([38a4178](https://github.com/amejiarosario/dsa.js/commit/38a4178e69e698a1b3c0d4452f0cfd58aed5290d)) + +# [2.7.0](https://github.com/amejiarosario/dsa.js/compare/2.6.0...2.7.0) (2020-10-30) + + +### Bug Fixes + +* **book/set:** split Set chapter into Hash Set and Tree Set for better ([c1cf57a](https://github.com/amejiarosario/dsa.js/commit/c1cf57a31fc7a698665c82c8fbd2fde7fb825078)) + + +### Features + +* **book:** show companies asked questions ([b3167f9](https://github.com/amejiarosario/dsa.js/commit/b3167f9c694c5e6719bf1d01804aeec60b41e57f)) +* **book/linkedlist:** add applications ([2b96f00](https://github.com/amejiarosario/dsa.js/commit/2b96f0086632d9ddcbb7e8f76a061a46f90a65a0)) + +# [2.6.0](https://github.com/amejiarosario/dsa.js/compare/2.5.1...2.6.0) (2020-10-28) + + +### Bug Fixes + +* **test:** refactor tests ([571834a](https://github.com/amejiarosario/dsa.js/commit/571834a848d3b4c7d0dd8a94957b73724f3756ac)) + + +### Features + +* **book:** add chapter numbers ([0f13f90](https://github.com/amejiarosario/dsa.js/commit/0f13f907141d0ad9bb439d131aca6d1d882421ee)) +* **book/linkedlist:** linked lists techniques and common patterns ([8cd126d](https://github.com/amejiarosario/dsa.js/commit/8cd126d71a31473fefdbf0f0a9780cd7b128bcd6)) + +## [2.5.1](https://github.com/amejiarosario/dsa.js/compare/2.5.0...2.5.1) (2020-10-23) + + +### Bug Fixes + +* **linkedlist:** refactored methods and improve book images and ([ba110e2](https://github.com/amejiarosario/dsa.js/commit/ba110e26b2103265bb78809618c7e29c185acd70)) +* **linkedlist:** rename indexOf to getIndex to make it clearer ([fcf3db6](https://github.com/amejiarosario/dsa.js/commit/fcf3db6ade12a7ed88a5b7756945a8b090ac63b9)) + +# [2.5.0](https://github.com/amejiarosario/dsa.js/compare/2.4.0...2.5.0) (2020-10-22) + + +### Features + +* **book/hashmap:** add code examples and patterns ([f7b8d59](https://github.com/amejiarosario/dsa.js/commit/f7b8d59ac8cbddacc34cac6a2f6e0a58419813fd)) + +# [2.4.0](https://github.com/amejiarosario/dsa.js/compare/2.3.0...2.4.0) (2020-10-19) + + +### Bug Fixes + +* **book/array:** improve examples and grammar ([04836cd](https://github.com/amejiarosario/dsa.js/commit/04836cd0cec3afb196d11704a45933e325816c20)) + + +### Features + +* **book/array:** add array patterns for solving problems ([8c7b7be](https://github.com/amejiarosario/dsa.js/commit/8c7b7be8fe24ec1df66846b05fbc2ef5daeb6c7e)) +* **book/array:** sliding window pattern ([8fa2746](https://github.com/amejiarosario/dsa.js/commit/8fa2746f5c917b0f5a88289d854166210925f9c7)) + +# [2.3.0](https://github.com/amejiarosario/dsa.js/compare/2.2.1...2.3.0) (2020-10-03) + + +### Features + +* **treeMap:** get last entry (highest value) ([249de5d](https://github.com/amejiarosario/dsa.js/commit/249de5d4769549e9f05562bb6dad50d4e0384524)) + +## [2.2.1](https://github.com/amejiarosario/dsa.js/compare/2.2.0...2.2.1) (2020-10-02) + + +### Bug Fixes + +* **book:** add introduction ([4505eb6](https://github.com/amejiarosario/dsa.js/commit/4505eb64a63b282ca9685b3b2cabb657149d9fe7)) + +# [2.2.0](https://github.com/amejiarosario/dsa.js/compare/2.1.0...2.2.0) (2020-09-29) + + +### Features + +* **book/big-o:** add new chapter on how to determine big o from code. ([68c73d4](https://github.com/amejiarosario/dsa.js/commit/68c73d4c3bb5fb1ec637d81b42a2f8dbfc4f0008)) + +# [2.1.0](https://github.com/amejiarosario/dsa.js/compare/2.0.0...2.1.0) (2020-09-11) + + +### Features + +* **book/sorting:** add questions and solutions ([fdb8bd8](https://github.com/amejiarosario/dsa.js/commit/fdb8bd8af644ddeaa07ce62773e9be96fd6b2404)) + +# [2.0.0](https://github.com/amejiarosario/dsa.js/compare/1.18.0...2.0.0) (2020-09-08) + + +### Features + +* **book/pq:** add exercise with pq and dijkstra ([3a2a24f](https://github.com/amejiarosario/dsa.js/commit/3a2a24ffae2af5e5e348c237195f7a39717ae617)) +* **heap:** add error handling for heaps ([827177f](https://github.com/amejiarosario/dsa.js/commit/827177f6023f639db0c2cc267dceb0a27746038a)) +* **pq:** improves docs and usability of priority queues ([edf8808](https://github.com/amejiarosario/dsa.js/commit/edf8808970d57aaf397958d2cab1a6cc2e029d26)) + + +### BREAKING CHANGES + +* **heap:** size is now an attribute rather than a method. Similar to the built-in Map.size and Set.size + +# [1.18.0](https://github.com/amejiarosario/dsa.js/compare/1.17.0...1.18.0) (2020-09-07) + + +### Features + +* **book/graph:** add schedule exercise and solution ([6a83cf8](https://github.com/amejiarosario/dsa.js/commit/6a83cf8a5d454b26e3048aa4ca73e44eafca0ed3)) + +# [1.17.0](https://github.com/amejiarosario/dsa.js/compare/1.16.0...1.17.0) (2020-09-04) + + +### Features + +* **book/set:** add questions and solutions ([f40dc63](https://github.com/amejiarosario/dsa.js/commit/f40dc6314a14e1750146a19163b3b70c30f09d70)) + +# [1.16.0](https://github.com/amejiarosario/dsa.js/compare/1.15.0...1.16.0) (2020-09-03) + + +### Features + +* **book/hashmap:** add exercises and solutions ([d18186b](https://github.com/amejiarosario/dsa.js/commit/d18186b61c260e3ae2cc1267cadd16c8cb453e00)) + +# [1.15.0](https://github.com/amejiarosario/dsa.js/compare/1.14.0...1.15.0) (2020-09-02) + + +### Bug Fixes + +* **book/solutions:** fix missing solutions ([464417e](https://github.com/amejiarosario/dsa.js/commit/464417e37ccde00d56d8ebb9c0d0ddc9e510e368)) + + +### Features + +* **BinaryTreeNode:** add BinaryTreeNode.from ([bcb4c28](https://github.com/amejiarosario/dsa.js/commit/bcb4c28089a96248ab9d623c25e1719e030caedc)) +* **book/binary-tree:** add right side view exercise and solution ([28346a4](https://github.com/amejiarosario/dsa.js/commit/28346a448e7f1be640751098b4a954ac04dd0aad)) +* **book/bt:** add binary tree diameter problem ([068dd9c](https://github.com/amejiarosario/dsa.js/commit/068dd9cc66e5a3050cc44d4cd3a05eb15f8c00d1)) + +# [1.14.0](https://github.com/amejiarosario/dsa.js/compare/1.13.0...1.14.0) (2020-08-31) + + +### Features + +* **book/questions:** add examples ([c1a8f8e](https://github.com/amejiarosario/dsa.js/commit/c1a8f8ec53f6c4c1302001dba6d913c81156fd98)) +* **book/questions:** add where the interview questions have been seen ([1f01baf](https://github.com/amejiarosario/dsa.js/commit/1f01bafdb55dcd82f6b88bdf1252c5aabb39277a)) +* **book/queue:** add recent counter questions and solution ([77d4596](https://github.com/amejiarosario/dsa.js/commit/77d459642ca61f729e698c892928665e76532701)) +* **book/queue:** add solution for queue question ([9a88766](https://github.com/amejiarosario/dsa.js/commit/9a887660bd21e7dbda0d3e87af704b4e41874093)) +* **queue:** add front, back and peek methods ([04aa9db](https://github.com/amejiarosario/dsa.js/commit/04aa9db26659058c09debe985f94845933a2089d)) + +# [1.13.0](https://github.com/amejiarosario/dsa.js/compare/1.12.0...1.13.0) (2020-08-26) + + +### Features + +* **book/exercises:** interview q&a for linked lists and stacks ([3bb86fd](https://github.com/amejiarosario/dsa.js/commit/3bb86fd544f543906b5723aab1f26d5a75f13950)) + +# [1.12.0](https://github.com/amejiarosario/dsa.js/compare/1.11.0...1.12.0) (2020-08-26) + + +### Features + +* **book/exercises:** interview q&a for linked lists and stacks ([#69](https://github.com/amejiarosario/dsa.js/issues/69)) ([ca4bf45](https://github.com/amejiarosario/dsa.js/commit/ca4bf45369ef772f4861e7619d3ea74ddc41cde4)) + + +### Reverts + +* Revert "(book/exercises): interview q&a for linked lists and stacks (#69)" (#70) ([06bd3f6](https://github.com/amejiarosario/dsa.js/commit/06bd3f6a8542b111e4c9e3b5d41050094b153112)), closes [#69](https://github.com/amejiarosario/dsa.js/issues/69) [#70](https://github.com/amejiarosario/dsa.js/issues/70) + +# [1.11.0](https://github.com/amejiarosario/dsa.js/compare/1.10.0...1.11.0) (2020-08-22) + + +### Bug Fixes + +* **book:** multiple broken links and bump epub version ([57960e2](https://github.com/amejiarosario/dsa.js/commit/57960e2c4f483e779e8344e07406ce7d67d4d9b8)), closes [#60](https://github.com/amejiarosario/dsa.js/issues/60) +* **book:** workaround for c++ issue in asciidoc ([dbdef21](https://github.com/amejiarosario/dsa.js/commit/dbdef2141ac1449c649cc76790d7990374e78808)) + + +### Features + +* **book:** add appendix D with interview question solutions ([ca119f2](https://github.com/amejiarosario/dsa.js/commit/ca119f2b2fe5e4392a0b13278b5a6ba9e907952c)) +* **book:array:** add solutions for interview questions ([b5a00dd](https://github.com/amejiarosario/dsa.js/commit/b5a00dded45a1f4eeab3bbbdd68ccbcbf02419d3)) +* **book/array:** add max subarray questions and solution ([5935b95](https://github.com/amejiarosario/dsa.js/commit/5935b95ea761402b296e5a4fbd6e3643714bcaf9)) +* **book/array:** add stock questions and solution ([6ab8bc4](https://github.com/amejiarosario/dsa.js/commit/6ab8bc4449323b059888edf84d66c76c9e812f4e)) + +# [1.10.0](https://github.com/amejiarosario/dsa.js/compare/1.9.0...1.10.0) (2020-07-28) + + +### Features + +* **book/arrays:** add exercises ([bcaf819](https://github.com/amejiarosario/dsa.js/commit/bcaf81919cb889c1209c6d1e577b037047714c05)) + # [1.9.0](https://github.com/amejiarosario/dsa.js/compare/1.8.3...1.9.0) (2020-06-30) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3f0989d2..43e79136 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,24 +1,24 @@ # Contributing -We encourage any form of contribution, whether that be issues, comments, or pull requests. If you are going to be submitting a PR, there are a few things we would appreciate that you do to keep the codebase clean: +We encourage any form of contribution, whether that will be issues, comments, or pull requests. If you are willing to submit a PR, there are a few things we would appreciate that you do to keep the codebase clean: -* **Write tests.** We try as close to 100% code coverage as possible on this repo so any new code that gets written should have accompanying tests. +* **Write tests (if applicable).** We try as close to 100% code coverage as possible on this repo, so any new code that gets written should have accompanying tests. * **Follow the linter.** We use our [ESLint configuration with Airbnb JavaScript Styleguide](https://github.com/airbnb/javascript), and we run `npm run lint` in our Travis builds. * **Ask questions if you aren't sure.** If you have any questions while implementing a fix or feature, feel free to create an issue and ask us. We're happy to help! -## Submission Guidelines +## Submission Guidelines -### Submitting an Issue +### Submitting an Issue -Before you submit an issue, please search the issue tracker, maybe an issue for your problem already exists and the discussion might inform you of workarounds readily available. +Before you submit an issue, please search the issue tracker, maybe an issue for your problem already exists, and the discussion might inform you of workarounds readily available. ### Submitting a Pull Request (PR) -Before you submit your Pull Request (PR) consider the following guidelines: +Before you submit your Pull Request (PR), consider the following guidelines: 1. Search [GitHub](https://github.com/amejiarosario/dsa.js/pulls) for an open or closed PR that relates to your submission. You don't want to duplicate effort. -1. Be sure that an issue describes the problem you're fixing, or documents the design for the feature you'd like to add. - Discussing the design up front helps to ensure that we're ready to accept your work. +1. Be sure that an issue describes the problem you're fixing or documents the design for the feature you'd like to add. + Discussing the design upfront helps to ensure that we're ready to accept your work. 1. Fork the `amejiarosario/dsa.js` repo. 1. Make your changes in a new git branch: @@ -29,14 +29,13 @@ Before you submit your Pull Request (PR) consider the following guidelines: 1. Create your patch, **including appropriate test cases**. 1. Run the full test suite, and ensure that all tests pass. 1. Commit your changes using a descriptive commit message that follows our - [commit message conventions](#commit). Adherence to these conventions - is necessary because release notes are automatically generated from these messages. + [commit message conventions](#commit). Adherence to these conventions is necessary because release notes are automatically generated from these messages. ```shell git commit -a ``` - Note: the optional commit `-a` command line option will automatically "add" and "rm" edited files. + Note: the optional commit `-a` command-line option will automatically "add" and "rm" edited files. 1. Push your branch to GitHub: @@ -88,8 +87,8 @@ from the main (upstream) repository: ## Commit Message Guidelines -We have some guidelines how our git commit messages can be formatted. This leads to **more -readable messages** that are easy to follow when looking through the **project history**. But also, +We have some guidelines on how our git commit messages can be formatted. These rules lead to more +readable messages that are easy to follow when looking through the project history. But also, we use the git commit messages to **generate the change log**. ### Commit Message Format @@ -104,35 +103,37 @@ format that includes a **type**, a **scope** and a **subject**: