Skip to content

[pull] master from amejiarosario:master #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 251 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
251 commits
Select commit Hold shift + click to select a range
c1eda1d
Merge pull request #27 from monners/master
amejiarosario Aug 11, 2019
69afe33
change the stable properties
archanaserver Aug 16, 2019
3cb3cec
Merge pull request #28 from archanaserver/patch-1
amejiarosario Aug 16, 2019
98f0dfb
release: 1.3.4
amejiarosario Aug 16, 2019
b5aae35
fix typo
gerasimov Aug 19, 2019
3356e1f
Merge pull request #29 from gerasimov/patch-1
amejiarosario Aug 19, 2019
1fa9341
fix(tree-rotations): prevent losing nodes
amejiarosario Aug 23, 2019
ebb7be8
release: 1.3.5
amejiarosario Aug 23, 2019
72e3d68
style: fix eslint issue
amejiarosario Aug 23, 2019
d8ce2f5
update deps
amejiarosario Aug 23, 2019
8096f7c
release: 1.3.6
amejiarosario Aug 23, 2019
48fe6f3
Merge pull request #31 from amejiarosario/update-deps
amejiarosario Aug 23, 2019
98e2c03
fix(avl-tree): balance was not working properly
amejiarosario Aug 27, 2019
01ad65d
release: 1.3.7
amejiarosario Aug 27, 2019
22d0fb2
Merge pull request #34 from amejiarosario/beblueblue-question
amejiarosario Aug 27, 2019
2f202c1
fix yml file
amejiarosario Oct 15, 2019
c57cbfd
Update yaml file
amejiarosario Oct 17, 2019
06ef72a
Update README.md
bhagatapoorva Oct 31, 2019
8c0eca0
Merge pull request #36 from bhagatapoorva/master
amejiarosario Oct 31, 2019
f625d93
add examples
amejiarosario Nov 26, 2019
49d083b
fix lint errors
amejiarosario Nov 26, 2019
5628a27
Merge pull request #37 from amejiarosario/new-examples
amejiarosario Nov 26, 2019
ad15b5f
improve merge sort example
amejiarosario Jan 7, 2020
ac98583
fix(book): fix typo, array pop, and BST images
mdribera Feb 11, 2020
b9a41ba
Merge pull request #39 from mdribera/fix-typo-array-pop-and-bst-images
amejiarosario Feb 12, 2020
6f4585a
bump to 1.3.8
amejiarosario Feb 12, 2020
a53915f
fix(docs): fix typo for heaps
amejiarosario Feb 12, 2020
bb3ad9a
Merge pull request #40 from amejiarosario/version-bump
amejiarosario Feb 12, 2020
c7cb9fd
update twitter handler
amejiarosario Feb 12, 2020
6fbd551
docs: update twitter handler
amejiarosario Feb 12, 2020
bbfeb93
Merge pull request #41 from amejiarosario/fix-tw-handler
amejiarosario Feb 12, 2020
535afe6
subset/powerset problem
amejiarosario Mar 18, 2020
382872f
Merge branch 'master' of github.com:amejiarosario/dsa.js-data-structu…
amejiarosario Mar 18, 2020
bc51a7a
fix(book): fix table typos
amejiarosario Mar 19, 2020
2521d1e
docs: add new changelog and exercises
amejiarosario Mar 19, 2020
bbe69dd
Merge pull request #42 from amejiarosario/fix-table
amejiarosario Mar 19, 2020
a0e0fd8
feat(trie): implement trie data structure
amejiarosario Mar 22, 2020
524670e
simplify backtracking algorithm
amejiarosario Mar 22, 2020
19ff1f0
initial updates
Mar 23, 2020
9c36253
style(book): better wording for table
amejiarosario Mar 23, 2020
18b699e
bump version
amejiarosario Mar 23, 2020
a36179f
Merge pull request #45 from amejiarosario/v-tank/fix-suggestions
amejiarosario Mar 23, 2020
16005f3
feat(trie): remove method
amejiarosario Mar 22, 2020
eac045a
feat(linkedList): remove by node
amejiarosario Mar 27, 2020
3e787c6
feat(lru-cache): add new implementations
amejiarosario Mar 27, 2020
a81f6e1
feat(trie): remove method
amejiarosario Mar 22, 2020
e31cc62
feat(trie): feature complete
amejiarosario Mar 27, 2020
715cd95
build: add cz-changelog
amejiarosario Mar 29, 2020
e8c01e4
build(build): install husky and commitizen
amejiarosario Mar 29, 2020
efd4e29
:wrench: chore (build) Automate git commit messages
amejiarosario Mar 29, 2020
7da7a46
:wrench: chore (build) semantic release
amejiarosario Mar 29, 2020
03a420d
:wrench: chore (build):
amejiarosario Mar 29, 2020
fd8aa2e
:wrench: chore (ci): improve ci
amejiarosario Mar 30, 2020
696fc42
:wrench: chore (docs): simplify contributing
amejiarosario Mar 30, 2020
d671882
Merge pull request #46 from amejiarosario/feature/auto-changelog
amejiarosario Mar 30, 2020
9d25b28
:wrench: chore (ci): format tags
amejiarosario Mar 30, 2020
567c110
Merge pull request #47 from amejiarosario/automate-releases
amejiarosario Mar 30, 2020
965fbd1
Merge pull request #43 from amejiarosario/feature/trie
amejiarosario Mar 30, 2020
43041ad
:wrench: chore (build): automate changelog creation
amejiarosario Mar 30, 2020
93543c4
Merge pull request #48 from amejiarosario/automate-changelog-creation
amejiarosario Mar 30, 2020
e8ca8b7
Merge branch 'master' into feature/lru-cache
amejiarosario Mar 30, 2020
76854c6
Merge pull request #49 from amejiarosario/feature/lru-cache
amejiarosario Mar 30, 2020
bcc81b4
:bookmark: chore(release): 1.5.0
semantic-release-bot Mar 30, 2020
64a4a4f
chore(lab): add new exercises
amejiarosario May 6, 2020
874f3eb
:sparkles: feat (heap): Add Heap implementation (PriorityQueue) (#51)
amejiarosario May 8, 2020
a4b87e8
:wrench: chore (ci): adjust semantic-release (#52)
amejiarosario May 8, 2020
419fd11
chore(semantic-release): fix matchers
amejiarosario May 8, 2020
7279e5c
:wrench: chore (readme): update ci link
amejiarosario May 8, 2020
f4d0670
Merge pull request #53 from amejiarosario/chore/sematic-release
amejiarosario May 8, 2020
28da0e1
:bookmark: chore(release): 1.6.0
semantic-release-bot May 8, 2020
202ca9f
feat(heap): add min/max/median-heaps
amejiarosario May 16, 2020
1bb097d
chore(docs): add comments
amejiarosario May 16, 2020
7e19bdc
Merge branch 'master' into chore/sematic-release
amejiarosario May 16, 2020
517fec4
Merge pull request #54 from amejiarosario/chore/sematic-release
amejiarosario May 16, 2020
142c301
:bookmark: chore(release): 1.7.0
semantic-release-bot May 16, 2020
c253938
Better hash function
nuintun May 20, 2020
6974354
Merge pull request #56 from nuintun/patch-1
amejiarosario May 20, 2020
e13ff88
fix(hashmap): fix TextEncoder reference
amejiarosario May 20, 2020
a24c0d7
Merge pull request #57 from amejiarosario/hotfix/hashmap
amejiarosario May 20, 2020
8ea61ce
:bookmark: chore(release): 1.7.1
semantic-release-bot May 20, 2020
f6b47b5
fix(hashmap): improve methods documentation
amejiarosario May 23, 2020
924c9a7
feat(maps): implement clear method for hashMap and treeMap
amejiarosario May 23, 2020
2f24f57
fix(book/map): fix typo on maps space complexity
amejiarosario May 23, 2020
b5c7426
Merge pull request #58 from amejiarosario/feature/hashmap
amejiarosario May 23, 2020
7284619
:bookmark: chore(release): 1.8.0
semantic-release-bot May 23, 2020
3c4ef75
fix(book/maps): update time/space complexity values
amejiarosario May 24, 2020
0412eeb
Merge pull request #59 from amejiarosario/hotfix/hashmap
amejiarosario May 24, 2020
81c5f0d
:bookmark: chore(release): 1.8.1
semantic-release-bot May 24, 2020
0319b29
fix(book/hashset): update hashset space complexity
amejiarosario May 24, 2020
0344298
Merge pull request #61 from amejiarosario/hotfix/hashmap
amejiarosario May 24, 2020
aac8160
:bookmark: chore(release): 1.8.2
semantic-release-bot May 24, 2020
0be0176
fix(book/maps): update space complexity
amejiarosario May 24, 2020
63fd518
Merge pull request #62 from amejiarosario/hotfix/hashmap
amejiarosario May 24, 2020
f484075
:bookmark: chore(release): 1.8.3
semantic-release-bot May 24, 2020
288ff77
chore(book-quicksort): update time complexities
amejiarosario May 25, 2020
75f8d11
chore(benchmarks): new files for benchmarks
amejiarosario May 25, 2020
f3fe049
chore(book/sorting): fix bubble sort reference
amejiarosario May 25, 2020
9874647
Merge pull request #63 from amejiarosario/hotfix/sorting
amejiarosario May 26, 2020
1fa875f
feat(linkedList): takes iterables in the constructor
amejiarosario Jun 30, 2020
6af937f
feat(heap): remove by index
amejiarosario Jun 30, 2020
a93ac1b
chore(lab): add exercises
amejiarosario Jun 30, 2020
7e17577
Merge pull request #64 from amejiarosario/improvements
amejiarosario Jun 30, 2020
c7e5c31
:bookmark: chore(release): 1.9.0
semantic-release-bot Jun 30, 2020
3f99c56
chore(lab): add new exercises and fix comment:wq
amejiarosario Jul 9, 2020
8cabf9c
Merge pull request #65 from amejiarosario/new-exercises
amejiarosario Jul 10, 2020
bcaf819
feat(book/arrays): add exercises
amejiarosario Jul 28, 2020
6b33bc8
Merge pull request #66 from amejiarosario/feat/chapter-exercises
amejiarosario Jul 28, 2020
482bee0
:bookmark: chore(release): 1.10.0
semantic-release-bot Jul 28, 2020
cccadf8
chore: remove uxa
amejiarosario Aug 6, 2020
e5bd4b7
Merge branch 'master' of github.com:amejiarosario/dsa.js-data-structu…
amejiarosario Aug 19, 2020
3901188
chore(sorting): clean up variables
amejiarosario Aug 19, 2020
2fab838
add config test
amejiarosario Aug 20, 2020
4d75825
chore(jest): fix commands
amejiarosario Aug 20, 2020
b5a00dd
feat(book:array): add solutions for interview questions
amejiarosario Aug 20, 2020
996f7aa
chore(vscode): set colors
amejiarosario Aug 20, 2020
ca119f2
feat(book): add appendix D with interview question solutions
amejiarosario Aug 20, 2020
57960e2
fix(book): multiple broken links and bump epub version
amejiarosario Aug 21, 2020
5935b95
feat(book/array): add max subarray questions and solution
amejiarosario Aug 21, 2020
6ab8bc4
feat(book/array): add stock questions and solution
amejiarosario Aug 21, 2020
dbdef21
fix(book): workaround for c++ issue in asciidoc
amejiarosario Aug 22, 2020
9b356d9
Merge pull request #67 from amejiarosario/feat/add-exercises-solutions
amejiarosario Aug 22, 2020
e573929
:bookmark: chore(release): 1.11.0
semantic-release-bot Aug 22, 2020
f125511
chore(build): dockerfile
amejiarosario Aug 24, 2020
5466f28
Merge branch 'master' into chore/build-changes
amejiarosario Aug 24, 2020
738d6f3
chore(build): add Dockerfile
amejiarosario Aug 24, 2020
69f284d
chore(build): use jest config
amejiarosario Aug 24, 2020
db10bf7
chore(build): update ruby version
amejiarosario Aug 24, 2020
d3faa71
chore(build): remove deprecated dep
amejiarosario Aug 24, 2020
44fb6a2
Merge pull request #68 from amejiarosario/chore/build-changes
amejiarosario Aug 24, 2020
ca4bf45
feat(book/exercises): interview q&a for linked lists and stacks (#69)
amejiarosario Aug 26, 2020
06bd3f6
Revert "(book/exercises): interview q&a for linked lists and stacks (…
amejiarosario Aug 26, 2020
4cdfbf5
:bookmark: chore(release): 1.12.0
semantic-release-bot Aug 26, 2020
3bb86fd
feat(book/exercises): interview q&a for linked lists and stacks
amejiarosario Aug 26, 2020
3373f63
Merge pull request #71 from amejiarosario/revert-70-revert-69-feat/li…
amejiarosario Aug 26, 2020
263c9dc
:bookmark: chore(release): 1.13.0
semantic-release-bot Aug 26, 2020
04aa9db
feat(queue): add front, back and peek methods
amejiarosario Aug 28, 2020
9a88766
feat(book/queue): add solution for queue question
amejiarosario Aug 28, 2020
77d4596
feat(book/queue): add recent counter questions and solution
amejiarosario Aug 29, 2020
1f01baf
feat(book/questions): add where the interview questions have been seen
amejiarosario Aug 29, 2020
29b8dc8
chore(book): improve grammar
amejiarosario Aug 31, 2020
c1a8f8e
feat(book/questions): add examples
amejiarosario Aug 31, 2020
40d6b64
Merge pull request #72 from amejiarosario/feat/queue-interview-questions
amejiarosario Aug 31, 2020
e2f4af0
:bookmark: chore(release): 1.14.0
semantic-release-bot Aug 31, 2020
464417e
fix(book/solutions): fix missing solutions
amejiarosario Sep 1, 2020
068dd9c
feat(book/bt): add binary tree diameter problem
amejiarosario Sep 1, 2020
28346a4
feat(book/binary-tree): add right side view exercise and solution
amejiarosario Sep 2, 2020
bcb4c28
feat(BinaryTreeNode): add BinaryTreeNode.from
amejiarosario Sep 2, 2020
86201fb
chore(book/exercises): bst exercises after traversals
amejiarosario Sep 2, 2020
d07458d
Merge pull request #73 from amejiarosario/feat/tree-problems
amejiarosario Sep 2, 2020
1bfe522
:bookmark: chore(release): 1.15.0
semantic-release-bot Sep 2, 2020
d18186b
feat(book/hashmap): add exercises and solutions
amejiarosario Sep 3, 2020
2def4dc
Merge pull request #74 from amejiarosario/feat/hashmap-exercises
amejiarosario Sep 3, 2020
641b338
:bookmark: chore(release): 1.16.0
semantic-release-bot Sep 3, 2020
f40dc63
feat(book/set): add questions and solutions
amejiarosario Sep 4, 2020
75aa67a
chore(book/questions): improve function documentation
amejiarosario Sep 4, 2020
802e9d3
Merge pull request #75 from amejiarosario/feat/set-questions
amejiarosario Sep 4, 2020
8a92ba0
:bookmark: chore(release): 1.17.0
semantic-release-bot Sep 4, 2020
6a83cf8
feat(book/graph): add schedule exercise and solution
amejiarosario Sep 5, 2020
6b0e671
Merge pull request #76 from amejiarosario/feat/graph-questions
amejiarosario Sep 7, 2020
f248e42
:bookmark: chore(release): 1.18.0
semantic-release-bot Sep 7, 2020
3a2a24f
feat(book/pq): add exercise with pq and dijkstra
amejiarosario Sep 8, 2020
827177f
feat(heap): add error handling for heaps
amejiarosario Sep 8, 2020
edf8808
feat(pq): improves docs and usability of priority queues
amejiarosario Sep 8, 2020
c211644
Merge pull request #78 from amejiarosario/feat/priority-queue-exercise-2
amejiarosario Sep 8, 2020
65e302b
:bookmark: chore(release): 2.0.0
semantic-release-bot Sep 8, 2020
fdb8bd8
feat(book/sorting): add questions and solutions
amejiarosario Sep 11, 2020
cba73a1
update kindlegen
amejiarosario Sep 11, 2020
56e8823
Merge pull request #79 from amejiarosario/feat/sorting-questions
amejiarosario Sep 11, 2020
57b6eb9
:bookmark: chore(release): 2.1.0
semantic-release-bot Sep 11, 2020
b956708
chore(book): improves grammar
amejiarosario Sep 11, 2020
06d75d8
Merge pull request #80 from amejiarosario/feat/sorting-questions
amejiarosario Sep 12, 2020
69fa96b
chore: new exercise
amejiarosario Sep 22, 2020
2e77826
chore: placeholder for exercises
amejiarosario Sep 27, 2020
68c73d4
feat(book/big-o): add new chapter on how to determine big o from code.
amejiarosario Sep 29, 2020
dec47fb
Merge pull request #81 from amejiarosario/feat/revision-part-one
amejiarosario Sep 29, 2020
29f374a
:bookmark: chore(release): 2.2.0
semantic-release-bot Sep 29, 2020
1392938
Update introduction.asc
dahalnischal Oct 2, 2020
e679993
Merge pull request #83 from amejiarosario/feat/divide-and-conquer-exe…
amejiarosario Oct 2, 2020
4505eb6
fix(book): add introduction
amejiarosario Oct 2, 2020
db19ea9
Merge pull request #84 from amejiarosario/patch-2
amejiarosario Oct 2, 2020
b047c23
:bookmark: chore(release): 2.2.1
semantic-release-bot Oct 2, 2020
249de5d
feat(treeMap): get last entry (highest value)
amejiarosario Oct 3, 2020
3b079c0
Merge pull request #85 from amejiarosario/feat/tree-map-improvements
amejiarosario Oct 3, 2020
1b2d612
:bookmark: chore(release): 2.3.0
semantic-release-bot Oct 3, 2020
1287f29
Update CONTRIBUTING.md
PokhrelAnish Oct 4, 2020
9175b62
Update CONTRIBUTING.md
PokhrelAnish Oct 4, 2020
f5169b5
chore: add examples to contributing
amejiarosario Oct 4, 2020
8135449
chore: improves docs grammar
amejiarosario Oct 4, 2020
f7ebb75
Merge pull request #87 from amejiarosario/PokhrelAnish/master
amejiarosario Oct 4, 2020
04836cd
fix(book/array): improve examples and grammar
amejiarosario Oct 2, 2020
8c7b7be
feat(book/array): add array patterns for solving problems
amejiarosario Oct 17, 2020
8fa2746
feat(book/array): sliding window pattern
amejiarosario Oct 19, 2020
603afc2
Merge pull request #88 from amejiarosario/feat/arrays
amejiarosario Oct 19, 2020
273a9dc
:bookmark: chore(release): 2.4.0
semantic-release-bot Oct 19, 2020
4ba6fe0
chore(book/array): improve exercises
amejiarosario Oct 19, 2020
dc47b76
Merge pull request #89 from amejiarosario/feat/arrays
amejiarosario Oct 19, 2020
f7b8d59
feat(book/hashmap): add code examples and patterns
amejiarosario Oct 22, 2020
edf11d9
Merge pull request #91 from amejiarosario/feat/hashmap
amejiarosario Oct 22, 2020
0d7a14b
:bookmark: chore(release): 2.5.0
semantic-release-bot Oct 22, 2020
7659ac6
chore(docs): improve comments here and there
amejiarosario Oct 23, 2020
fcf3db6
fix(linkedlist): rename indexOf to getIndex to make it clearer
amejiarosario Oct 23, 2020
ba110e2
fix(linkedlist): refactored methods and improve book images and
amejiarosario Oct 23, 2020
2c8d383
Merge pull request #92 from amejiarosario/feat/linkedlist
amejiarosario Oct 23, 2020
0e12523
:bookmark: chore(release): 2.5.1
semantic-release-bot Oct 23, 2020
0f13f90
feat(book): add chapter numbers
amejiarosario Oct 25, 2020
8cd126d
feat(book/linkedlist): linked lists techniques and common patterns
amejiarosario Oct 27, 2020
571834a
fix(test): refactor tests
amejiarosario Oct 28, 2020
22972c3
Merge pull request #93 from amejiarosario/feat/linkedlist
amejiarosario Oct 28, 2020
bd9e1e4
:bookmark: chore(release): 2.6.0
semantic-release-bot Oct 28, 2020
c1cf57a
fix(book/set): split Set chapter into Hash Set and Tree Set for better
amejiarosario Oct 30, 2020
2b96f00
feat(book/linkedlist): add applications
amejiarosario Oct 30, 2020
6c39aae
chore(book): improve grammar of various chapters
amejiarosario Oct 30, 2020
b3167f9
feat(book): show companies asked questions
amejiarosario Oct 30, 2020
1fced28
Merge pull request #94 from amejiarosario/feat/set-improvements
amejiarosario Oct 30, 2020
b3039ab
:bookmark: chore(release): 2.7.0
semantic-release-bot Oct 30, 2020
38a4178
fix(book): update company names
amejiarosario Dec 2, 2020
d70aec2
Merge pull request #95 from amejiarosario/fix/update-companies
amejiarosario Dec 2, 2020
96cc1cb
:bookmark: chore(release): 2.7.1
semantic-release-bot Dec 2, 2020
b2a82c0
Rename fibonacci-dynamic-programming (fix typo)
knoxknox Dec 16, 2020
ded0a70
fix(book): Rename fibonacci-dynamic-programming
knoxknox Dec 16, 2020
5b0d703
Merge pull request #97 from amejiarosario/fix/typo
amejiarosario Dec 17, 2020
7dd9df8
Merge pull request #96 from knoxknox/fix-naming
amejiarosario Dec 17, 2020
65b6edd
:bookmark: chore(release): 2.7.2
semantic-release-bot Dec 17, 2020
c137930
fix(book/hashmap): exercise example and add tests
amejiarosario Dec 22, 2020
c7c7947
fix(book/graph): add comments for runtimes using hashset implementations
amejiarosario Dec 22, 2020
1d75301
fix(book/bst): better wording
amejiarosario Dec 22, 2020
436848d
fixes format
amejiarosario Dec 22, 2020
4350fca
Merge pull request #98 from amejiarosario/fix/sam-findings
amejiarosario Dec 22, 2020
3c32d0e
:bookmark: chore(release): 2.7.3
semantic-release-bot Dec 22, 2020
6b9a4e8
fix(bst): some typos on the code
amejiarosario Jan 9, 2021
2090ea2
:bookmark: chore(release): 2.7.4
semantic-release-bot Jan 9, 2021
1812da7
Update README.md
amejiarosario Feb 11, 2021
cec3b04
chore(graph): fix typo
amejiarosario May 18, 2021
d350da8
fix(bst): on duplicates values the same node is returned
amejiarosario May 24, 2021
1c05026
Merge pull request #100 from amejiarosario/fix/nadhem-findings
amejiarosario May 24, 2021
03bafbb
:bookmark: chore(release): 2.7.5
semantic-release-bot May 24, 2021
e03875d
Update tree-intro.asc
eraygundogmus Sep 13, 2021
9243b24
Merge pull request #104 from eraygundogmus/patch-1
amejiarosario Sep 23, 2021
5ac3cd9
Update quick-sort.asc
ivanji Nov 9, 2021
02d9f48
Merge pull request #107 from ivanji/patch-2
amejiarosario Nov 14, 2021
ccfcfe6
fix(graph): minor typo in bfs code documentation
onethirtyfive Nov 27, 2021
438e8dd
Merge pull request #111 from onethirtyfive/fix-graph-bfs-documentation
amejiarosario Nov 30, 2021
ae41553
:bookmark: chore(release): 2.7.6
semantic-release-bot Nov 30, 2021
5b49d8a
fix(runtimes/02-binary-search):fixes binary search iterative
gabrielastelescu May 19, 2022
cde6e8a
Update heap.js
Balaji1202 May 29, 2022
c9249d3
chore(binary-search): consolidate test for multiple implementations
amejiarosario Dec 10, 2022
41205d6
Merge pull request #113 from gabrielastelescu/binary-search-iterative
amejiarosario Dec 10, 2022
c20acfb
Merge pull request #114 from Balaji1202/patch-1
amejiarosario Dec 20, 2022
fefb06a
Fix return of unshift method
caiquecastro Dec 26, 2022
844644d
Merge pull request #117 from caiquecastro/patch-1
amejiarosario Dec 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 77 additions & 12 deletions book/D-interview-questions-solutions.asc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ include::interview-questions/max-subarray.js[tag=description]
include::interview-questions/max-subarray.js[tag=solution]
----

The runtime is `O(n)` and space complexity of `O(1)`.
The runtime is `O(n)` and the space complexity of `O(1)`.



Expand Down Expand Up @@ -90,11 +90,10 @@ Algorithm:

[source, javascript]
----
include::interview-questions/buy-sell-stock.js[tag=description]
include::interview-questions/buy-sell-stock.js[tag=solution]
include::interview-questions/buy-sell-stock.js[tag=description,solution]
----

The runtime is `O(n)` and space complexity of `O(1)`.
The runtime is `O(n)` and the space complexity of `O(1)`.



Expand Down Expand Up @@ -126,8 +125,7 @@ Another case to take into consideration is that lists might have different lengt

[source, javascript]
----
include::interview-questions/merge-lists.js[tag=description]
include::interview-questions/merge-lists.js[tag=solution]
include::interview-questions/merge-lists.js[tag=description,solution]
----

Notice that we used a "dummy" node or "sentinel node" to have some starting point for the final list.
Expand Down Expand Up @@ -159,7 +157,7 @@ include::interview-questions/linkedlist-same-data.js[tag=hasSameDataBrute1]

Notice that the problem mentions that lists could be huge (millions of nodes). If the first character on each list is different, we are unnecessarily computing millions of nodes, when a straightforward check will do the job.

A better way to solve this problem is iterating over each character on both lists, and when we found mistmatch, we return `false` immediately. If they are the same, we still have to visit all of them.
A better way to solve this problem is iterating over each character on both lists, and when we found a mismatch, we return `false` immediately. If they are the same, we still have to visit all of them.

*Algorithm*:

Expand All @@ -172,12 +170,11 @@ A better way to solve this problem is iterating over each character on both list

[source, javascript]
----
include::interview-questions/linkedlist-same-data.js[tag=description]
include::interview-questions/linkedlist-same-data.js[tag=solution]
include::interview-questions/linkedlist-same-data.js[tag=description,solution]
----

The function `findNextPointerIndex` is a helper to navigate each character on a linked list.
Notice, that we increase the index (`i + 1`) on each iteration.
Notice that we increase the index (`i + 1`) on each iteration.
If the index overflows, it moves to the next node and reset the index to zero.


Expand Down Expand Up @@ -207,7 +204,7 @@ This is a parsing problem, and usually, stacks are good candidates for them.

*Algorithm*:

- Create a mapping for each opening bracket, to its closing counterpart.
- Create a mapping for each opening bracket to its closing counterpart.
- Iterate through the string
- When we found an opening bracket, insert the corresponding closing bracket into the stack.
- When we found a closing bracket, pop from the stack and make sure it corresponds to the current character.
Expand Down Expand Up @@ -267,6 +264,75 @@ The stack contains the indexes rather than the temperatures themselves.



:leveloffset: +1

=== Solutions for Queue Questions
(((Interview Questions Solutions, Queue)))

:leveloffset: -1


[#queue-q-recent-counter]
include::content/part02/queue.asc[tag=queue-q-recent-counter]

We are asked to keep track of the request's count only within a given time window. A queue is a perfect application for this. We can add any new request to the Queue. Also, we need to check if the oldest element is outside the time window. If so, we remove it from the queue.

*Algorithm*:

- Enqueue new requests.
- Take a `peek` at the oldest request in the queue.
- While `current timestamp - oldest timestamp`, dequeue the oldest.
- Return the length of the queue.

*Implementation*:

[source, javascript]
----
include::interview-questions/recent-counter.js[tag=description,solution]
----

Notice that we enqueue every request, and then we check all the ones that have "expire" and remove them from the queue.

*Complexity Analysis*:

- Time: `O(n)`, where `n` is the number of requests. One Enqueue/Dequeue operation is O(1). However, we might run into a worst-case where all requests have to be dequeued.
- Space: `O(W)`, where `W` is the time window. We can have at most W requests in the queue since they are in increasing order without duplicates.


[#queue-q-design-snake-game]
include::content/part02/queue.asc[tag=queue-q-design-snake-game]

This game is perfect to practice working with Queues. There are at least two opportunities to use a Queue. You can enqueue the food location, and also you can keep the snake's body parts on a Queue. We insert a new position into the snake's queue on every move and dequeue the last location to indicate the snake moved. Every time the snake eats food, it grows one more unit. The food gets dequeue, and we place the next food location (if any).

*Algorithm*:

- Based on the snake's head current position, calculate the next location based on the given move `direction`.
- If the new position is outside the boundaries, it's game over (return -1).
- If the new location has food, remove that eaten food from its queue and place the next food on the map (if any).
- If the new position doesn't have food, remove the tail of the snake since it moved.
- If the snake new position hits itself, game over (return -1). To make this check, we have 2 options:
- Queue: we can visit all the elements on the snake's queue (body) and check if a new position collides. That's `O(n)`
- Set: we can maintain a `set` with all the snake locations, so the check is `O(1)`.
- Move the snake's head to a new location (enqueue)
- Return the score (snake's length - 1);

*Implementation*:

[source, javascript]
----
include::interview-questions/design-snake-game.js[tag=description,solution]
----

As you can see, we opted for using a set to trade speed for memory.

*Complexity Analysis*:

- Time: `O(1)`. Insert/Remove from Queue is constant time. Check for body collisions is `O(1)` when using a set. If instead of a set, you traversed the snake's queue to find a collision, it would be `O(n)`. Here`n` is the snake's max length, which is the size of the screen (height x width).
- Space: `O(n + m)`. `m` is the number of food items, and `n` is the snake's maximum size (height x width).




// [#linkedlist-q-FILENAME]
// include::content/part02/linked-list.asc[tag=linkedlist-q-FILENAME]

Expand All @@ -293,4 +359,3 @@ The stack contains the indexes rather than the temperatures themselves.

// - Time: `O(?)`. WHY?
// - Space: `O(?)`. WHY?

2 changes: 1 addition & 1 deletion book/config
25 changes: 24 additions & 1 deletion book/content/part02/array.asc
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,24 @@ To sum up, the time complexity of an array is:
|===
//end::table

==== Interview Questions
==== Practice Questions
(((Interview Questions, Arrays)))

// tag::array-q-max-subarray[]
===== Max Subarray

*AR-1*) _Given an array of integers, find the maximum sum of consecutive elements (subarray)._

Examples:

[source, javascript]
----
maxSubArray([1, -3, 10, -5]); // 10 (taking only 10)
maxSubArray([-3, 4,-1, 2, 1, -5]); // 6 (sum [4,-1, 2, 1])
maxSubArray([-2, 1, -3, 4, -1, 3, 1]); // 7 (sum [4,-1, 3, 1])
----

_Seen in interviews at: Amazon, Apple, Google, Microsoft, Facebook_
// end::array-q-max-subarray[]

[source, javascript]
Expand All @@ -298,6 +309,18 @@ _Solution: <>_
===== Best Time to Buy and Sell an Stock

*AR-2*) _You are given an array of integers. Each value represents the closing value of the stock on that day. You are only given one chance to buy and then sell. What's the maximum profit you can obtain? (Note: you have to buy first and then sell)_

Examples:

[source, javascript]
----
maxProfit([1, 2, 3]) // 2 (buying at 1 and selling at 3)
maxProfit([3, 2, 1]) // 2 (no buys)
maxProfit([5, 10, 5, 10]) // 5 (buying at 5 and selling at 10)
----

_Seen in interviews at: Amazon, Facebook, Bloomberg_
// end::array-q-buy-sell-stock[]

[source, javascript]
Expand Down
28 changes: 22 additions & 6 deletions book/content/part02/linked-list.asc
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,22 @@ Use a doubly linked list when:

For the next two linear data structures <> and <>, we are going to use a doubly-linked list to implement them. We could use an array as well, but since inserting/deleting from the start performs better with linked-lists, we will use that.

==== Interview Questions
(((Interview Questions, Arrays)))



==== Practice Questions
(((Interview Questions, Linked Lists)))

// tag::linkedlist-q-merge-lists[]
===== Merge Linked Lists into One

*LL-1*) _Merge two sorted lists into one (and keep them sorted)_

Examples:

----
mergeTwoLists(2->3->4, 1->2); // 1->2->2->3->4
mergeTwoLists(2->3->4,null); // 2->3->4
----

_Seen in interviews at: Amazon, Adobe, Microsoft, Google_
// end::linkedlist-q-merge-lists[]

[source, javascript]
Expand All @@ -313,7 +319,17 @@ _Solution: <>_
// tag::linkedlist-q-linkedlist-same-data[]
===== Check if two strings lists are the same

*LL-2*) _Given two linked lists with strings, check if are the same_
*LL-2*) _Given two linked lists with strings, check if the data is equivalent._

Examples:

----
hasSameData(he->ll->o, hel->lo); // true
hasSameData(hello, hel->lo); // true
hasSameData(he->ll->o, h->i); // false
----

_Seen in interviews at: Facebook_
// end::linkedlist-q-linkedlist-same-data[]

[source, javascript]
Expand Down
71 changes: 67 additions & 4 deletions book/content/part02/queue.asc
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ A queue is a linear data structure where the data flows in a *First-In-First-Out
.Queue data structure is like a line of people: the First-in, is the First-out
image::image30.png[image,width=528,height=171]

A queue is like a line of people at the bank; the person that arrived first is the first to go out as well.
A queue is like a line of people at the bank; the person who arrived first is the first to go out.

Similar to the stack, we only have two operations (insert and remove). In a Queue, we add elements to the back of the list and remove it from the front.

We could use an array or a linked list to implement a Queue. However, it is recommended only to use a linked list. Why? An array has a linear runtime _O(n)_ to remove an element from the start while a linked list has constant time _O(1)_.
We could use an array or a linked list to implement a Queue. However, it is recommended only to use a linked list. Why? An array has a linear runtime _O(n)_ to remove an element from the start, while a linked list has constant time _O(1)_.

.Queue's constructor
[source, javascript]
Expand Down Expand Up @@ -56,15 +56,15 @@ As discussed, this operation has a constant runtime.

==== Implementation usage

We can use our Queue class like follows:
We can use our Queue class as follows:

.Queue usage example
[source, javascript]
----
include::{codedir}/data-structures/queues/queue.js[tag=snippet, indent=0]
----

You can see that the items are dequeued in the same order they were added, FIFO (first-in, first out).
You can see that the items are dequeued in the same order they were added, FIFO (first-in, first-out).

==== Queue Complexity

Expand All @@ -81,3 +81,66 @@ As an experiment, we can see in the following table that if we had implemented t
|===
// end::table[]
indexterm:[Runtime, Linear]


==== Practice Questions
(((Interview Questions, Queue)))


// tag::queue-q-recent-counter[]
===== Recent Counter

*QU-1*) _Design a class that counts the most recent requests within a time window._

Example:

[source, javascript]
----
const counter = new RecentCounter(10); // The time window is 10 ms.
counter.request(1000); // 1 (first request, it always counts)
counter.request(3000); // 1 (last requests was 2000 ms ago, > 10ms, so doesn't count)
counter.request(3100); // 1 (last requests was 100 ms ago, > 10ms, so doesn't count)
counter.request(3105); // 2 (last requests was 5 ms ago, <= 10ms, so it counts)
----

_Seen in interviews at: Google, Bloomberg, Yandex_
// end::queue-q-recent-counter[]


[source, javascript]
----
include::../../interview-questions/recent-counter.js[tag=description]
// write you code here
}
----

_Solution: <>_


// tag::queue-q-design-snake-game[]
===== Design Snake Game

*QU-2*) _Design the `move` function for the snake game. The move function returns an integer representing the current score. If the snake goes out of the given height and width or hit itself the game is over and return `-1`._

Example:

[source, javascript]
----
const snakeGame = new SnakeGame(4, 2, [[1, 2], [0, 1]]);
expect(snakeGame.move('R')).toEqual(0); // 0
expect(snakeGame.move('D')).toEqual(0); // 0
expect(snakeGame.move('R')).toEqual(1); // 1 (ate food1)
expect(snakeGame.move('U')).toEqual(1); // 1
expect(snakeGame.move('L')).toEqual(2); // 2 (ate food2)
expect(snakeGame.move('U')).toEqual(-1); // -1 (hit wall)
----

_Seen in interviews at: Amazon, Bloomberg, Apple_
// end::queue-q-design-snake-game[]

[source, javascript]
----
include::../../interview-questions/design-snake-game.js[tag=description]
----

_Solution: <>_
31 changes: 25 additions & 6 deletions book/content/part02/stack.asc
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,26 @@ Implementing the stack with an array and linked list would lead to the same time
It's not very common to search for values on a stack (other Data Structures are better suited for this). Stacks are especially useful for implementing <>.


==== Interview Questions
(((Interview Questions, Arrays)))




==== Practice Questions
(((Interview Questions, Stack)))

// tag::stack-q-valid-parentheses[]
===== Validate Parentheses / Braces / Brackets

*ST-1*) _Given an string with 3 types of brakets: `()`, `{}`, and `[]`. Validate they are properly closed and opened._

Examples:

[source, javascript]
----
isParenthesesValid('(){}[]'); // true
isParenthesesValid('('); // false (closing parentheses is missing)
isParenthesesValid('([{}])'); // true
isParenthesesValid('[{]}'); // false (brakets are not closed in the right order)
isParenthesesValid('([{)}]'); // false (closing is out of order)
----

_Seen in interviews at: Amazon, Bloomberg, Facebook, Citadel_
// end::stack-q-valid-parentheses[]

[source, javascript]
Expand All @@ -117,6 +126,16 @@ _Solution: <>_
===== Daily Temperaturs

*ST-2*) _Given an array of integers from 30 to 100 (daily temperatures), return another array that for each day in the input, tells you how many days you would have to wait until a warmer temperature. If no warmer temperature is possible then return `0` for that element._

Examples:

[source, javascript]
----
dailyTemperatures([30, 28, 50, 40, 30]); // [2 (to 50), 1 (to 28), 0, 0, 0]
dailyTemperatures([73, 69, 72, 76, 73, 100]); // [3, 1, 1, 0, 1, 100]
----

_Seen in interviews at: Amazon, Adobe, Cisco_
// end::stack-q-daily-temperatures[]

[source, javascript]
Expand Down
Loading