Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feat/set improvements #94

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

Merged
amejiarosario merged 4 commits into master from feat/set-improvements
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
feat(book): show companies asked questions
  • Loading branch information
amejiarosario committed Oct 30, 2020
commit b3167f9c694c5e6719bf1d01804aeec60b41e57f
2 changes: 1 addition & 1 deletion book/content/part01/big-o-examples.asc
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Before we dive in, here’s a plot with all of them.

.CPU operations vs. Algorithm runtime as the input size grows
// image::image5.png[CPU time needed vs. Algorithm runtime as the input size increases]
image::big-o-running-time-complexity.png[CPU time needed vs. Algorithm runtime as the input size increases]
image::time-complexity-manual.png[{half-size}]

The above chart shows how the algorithm's running time is related to the CPU's work. As you can see, O(1) and O(log n) is very scalable. However, O(n^2^) and worst can convert your CPU into a furnace 🔥 for massive inputs.

Expand Down
4 changes: 2 additions & 2 deletions book/content/part02/array.asc
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ 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_
_Common in interviews at: Amazon, Apple, Google, Microsoft, Facebook_
// end::array-q-max-subarray[]

[source, javascript]
Expand All @@ -548,7 +548,7 @@ 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_
_Common in interviews at: Amazon, Facebook, Bloomberg_
// end::array-q-buy-sell-stock[]

[source, javascript]
Expand Down
4 changes: 2 additions & 2 deletions book/content/part02/hash-map.asc
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ Something that might look unnecessary is the `Math.max` when updating the `lo` p

// end::hashmap-q-two-sum[]

// _Seen in interviews at: Amazon, Google, Apple._
_Common in interviews at: Amazon, Google, Apple._

Examples:

Expand Down Expand Up @@ -656,7 +656,7 @@ _Solution: <<hashmap-q-two-sum>>_

// end::hashmap-q-subarray-sum-equals-k[]

// _Seen in interviews at: Facebook, Google, Amazon_
_Common in interviews at: Facebook, Google, Amazon_

Examples:

Expand Down
4 changes: 2 additions & 2 deletions book/content/part02/hash-set.asc
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Find the most common word that is not on the banned list.
You might need to sanitize the text and strip out punctuation `?!,'.`_
// end::set-q-most-common-word[]

// _Seen in interviews at: Amazon._
_Common in interviews at: Amazon._

Examples:

Expand Down Expand Up @@ -173,7 +173,7 @@ _Solution: <<set-q-most-common-word>>_

// end::set-q-longest-substring-without-repeating-characters[]

// _Seen in interviews at: Amazon, Facebook, Bloomberg._
_Common in interviews at: Amazon, Facebook, Bloomberg._

Examples:

Expand Down
4 changes: 2 additions & 2 deletions book/content/part02/linked-list.asc
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ 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_
_Common in interviews at: Amazon, Adobe, Microsoft, Google_
// end::linkedlist-q-merge-lists[]

[source, javascript]
Expand Down Expand Up @@ -612,7 +612,7 @@ hasSameData(hello, hel->lo); // true
hasSameData(he->ll->o, h->i); // false
----

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

[source, javascript]
Expand Down
4 changes: 2 additions & 2 deletions book/content/part02/queue.asc
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ counter.request(3100); // 1 (last requests was 100 ms ago, > 10ms, so doesn't co
counter.request(3105); // 2 (last requests was 5 ms ago, <= 10ms, so it counts)
----

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


Expand Down Expand Up @@ -135,7 +135,7 @@ 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_
_Common in interviews at: Amazon, Bloomberg, Apple_
// end::queue-q-design-snake-game[]

[source, javascript]
Expand Down
4 changes: 2 additions & 2 deletions book/content/part02/stack.asc
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ 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_
_Common in interviews at: Amazon, Bloomberg, Facebook, Citadel_
// end::stack-q-valid-parentheses[]

[source, javascript]
Expand Down Expand Up @@ -135,7 +135,7 @@ 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_
_Common in interviews at: Amazon, Adobe, Cisco_
// end::stack-q-daily-temperatures[]

[source, javascript]
Expand Down
4 changes: 2 additions & 2 deletions book/content/part03/binary-search-tree-traversal.asc
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Post-order traverval will return `3, 4, 5, 15, 40, 30, 10`.

// end::binary-tree-q-diameter-of-binary-tree[]

// _Seen in interviews at: Facebook, Amazon, Google_
_Common in interviews at: Facebook, Amazon, Google_

// Example 1:
// [graphviz, tree-diameter-example-1, png]
Expand Down Expand Up @@ -203,7 +203,7 @@ _Solution: <<binary-tree-q-diameter-of-binary-tree>>_

// end::binary-tree-q-binary-tree-right-side-view[]

// _Seen in interviews at: Facebook, Amazon, ByteDance (TikTok)._
_Common in interviews at: Facebook, Amazon, ByteDance (TikTok)._

Examples:

Expand Down
4 changes: 2 additions & 2 deletions book/content/part03/graph-search.asc
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ NOTE: Every tree is a graph, but not every graph is a tree. Only acyclic directe

// end::graph-q-course-schedule[]

// _Seen in interviews at: Amazon, Facebook, Bytedance (TikTok)._
_Common in interviews at: Amazon, Facebook, Bytedance (TikTok)._


*Starter code*:
Expand Down Expand Up @@ -155,7 +155,7 @@ _Solution: <<graph-q-course-schedule>>_

// end::graph-q-critical-connections-in-a-network[]

// _Seen in interviews at: Amazon, Google._
_Common in interviews at: Amazon, Google._

Examples:

Expand Down
2 changes: 1 addition & 1 deletion book/content/part04/algorithmic-toolbox.asc
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ TIP: TL;DR: Don't start coding right away. First, solve the problem, then write
. *Test* your algorithm idea with multiple examples
. *Optimize* the solution –Only optimize when you have something working. Don't try to do both at the same time!
.. Can you trade-off space for speed? Use a <<hashmap-chap>> to speed up results!
.. Do you have a bunch of recursive and overlapping problems? Try <<Dynamic Programming>>.
.. Do you have a bunch of recursive and overlapping problems? Try <<dynamic-programming-chap>>.
.. Re-read requirements and see if you can take advantage of anything. E.g. is the array sorted?
. *Write Code*, yes, now you can code.
.. Modularize your code with functions (don't do it all in one giant function, please 🙏)
Expand Down
6 changes: 3 additions & 3 deletions book/content/part04/divide-and-conquer.asc
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ We have already implemented some algorithms using the divide and conquer techniq

.Examples of divide and conquer algorithms:
- <<part04-algorithmic-toolbox#merge-sort>>: *divides* the input into pairs, sort them, and them *join* all the pieces in ascending order.
- <<part04-algorithmic-toolbox#quicksort>>: *splits* the data by a random number called "pivot," then move everything smaller than the pivot to the left and anything more significant to the right. Repeat the process on the left and right sides. Note: since this works in place doesn't need a "join" part.
- <<quicksort-chap>>: *splits* the data by a random number called "pivot," then move everything smaller than the pivot to the left and anything more significant to the right. Repeat the process on the left and right sides. Note: since this works in place doesn't need a "join" part.
- <<part01-algorithms-analysis#logarithmic-example, Binary Search>>: find a value in a sorted collection by *splitting* the data in half until it sees the value.
- <<part01-algorithms-analysis#factorial-example, Permutations>>: *Take out* the first element from the input and solve permutation for the remainder of the data recursively, then *join* results and append the items that were taken out.

Expand Down Expand Up @@ -117,7 +117,7 @@ For these cases, when subproblems repeat themselves, we can optimize them using

// // end::divide-and-conquer-q-FILENAME[]

// // _Seen in interviews at: X._
// _Common in interviews at: X._

// *Starter code*:

Expand Down Expand Up @@ -148,7 +148,7 @@ For these cases, when subproblems repeat themselves, we can optimize them using

// // end::divide-and-conquer-q-FILENAME[]

// // _Seen in interviews at: X._
// _Common in interviews at: X._

// *Starter code*:

Expand Down
1 change: 1 addition & 0 deletions book/content/part04/dynamic-programming.asc
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ endif::[]

(((Dynamic Programming)))
(((Algorithmic Techniques, Dynamic Programming)))
[[dynamic-programming-chap]]
=== Dynamic Programming

Dynamic programming (DP) is a way to solve algorithmic problems with *overlapping subproblems*. Algorithms using DP find the base case and building a solution from the ground-up. Dp _keep track_ of previous results to avoid re-computing the same operations.
Expand Down
5 changes: 3 additions & 2 deletions book/content/part04/quick-sort.asc
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ ifndef::imagesdir[]
:codedir: ../../../src
endif::[]

[[Quicksort]]
==== Quicksort
(((Sorting, QuickSort)))
(((QuickSort)))
[[quicksort-chap]]
==== Quicksort

Quicksort is an efficient recursive sorting algorithm that uses <<Divide and Conquer, divide and conquer>> paradigm to sort faster. It can be implemented in-place, so it doesn't require additional memory.

indexterm:[Divide and Conquer]
Expand Down
10 changes: 5 additions & 5 deletions book/content/part04/sorting-algorithms.asc
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ We can sort to get the maximum or minimum value, and many algorithmic problems c

.and then discuss efficient sorting algorithms _O(n log n)_ such as:
- <<part04-algorithmic-toolbox#merge-sort>>
- <<part04-algorithmic-toolbox#quicksort>>
- <<quicksort-chap>>

Before we dive into the most well-known sorting algorithms, let's discuss the sorting properties.

Expand Down Expand Up @@ -124,7 +124,7 @@ We explored the most common sorting algorithms, some of which are simple and oth
| <<part04-algorithmic-toolbox#insertion-sort>> | Look for biggest number to the left and swap it with current
| <<part04-algorithmic-toolbox#selection-sort>> | Iterate array looking for smallest value to the right
| <<part04-algorithmic-toolbox#merge-sort>> | Split numbers in pairs, sort pairs and join them in ascending order
| <<part04-algorithmic-toolbox#quicksort>> | Choose a pivot, set smaller values to the left and bigger to the right.
| <<quicksort-chap>> | Choose a pivot, set smaller values to the left and bigger to the right.
// | Tim sort | Hybrid of merge sort and insertion sort
|===

Expand All @@ -135,7 +135,7 @@ We explored the most common sorting algorithms, some of which are simple and oth
| <<part04-algorithmic-toolbox#insertion-sort>> | O(n^2^) | O(n) | O(n^2^) | O(1) | Yes | Yes | Yes | Yes
| <<part04-algorithmic-toolbox#selection-sort>> | O(n^2^) | O(n^2^) | O(n^2^) | O(1) | No | Yes | No | No
| <<part04-algorithmic-toolbox#merge-sort>> | O(n log n) | O(n log n) | O(n log n) | O(n) | Yes | No | No | No
| <<part04-algorithmic-toolbox#quicksort>> | O(n log n) | O(n log n) | O(n^2^) | O(log n) | No | Yes | No | No
| <<quicksort-chap>> | O(n log n) | O(n log n) | O(n^2^) | O(log n) | No | Yes | No | No
// | Tim sort | O(n log n) | O(log n) | Yes | No | No | Yes
|===
// end::table[]
Expand All @@ -162,7 +162,7 @@ We explored the most common sorting algorithms, some of which are simple and oth

// end::sorting-q-merge-intervals[]

// _Seen in interviews at: Facebook, Amazon, Bloomberg._
_Common in interviews at: Facebook, Amazon, Bloomberg._

*Starter code*:

Expand Down Expand Up @@ -195,7 +195,7 @@ _Solution: <<sorting-q-merge-intervals>>_

// end::sorting-q-sort-colors[]

// _Seen in interviews at: Amazon, Microsoft, Facebook._
_Common in interviews at: Amazon, Microsoft, Facebook._

*Starter code*:

Expand Down
Binary file added book/images/time-complexity-manual.png
View file Open in desktop
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
[フレーム]
2 changes: 1 addition & 1 deletion book/part04-algorithmic-toolbox.asc
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Later, you will learn some algorithmic paradigms that will help you identify com

.We are going to discuss the following techniques for solving algorithms problems:
- <<Greedy Algorithms>>: makes greedy choices using heuristics to find the best solution without looking back.
- <<Dynamic Programming>>: a technique for speeding up recursive algorithms when there are many _overlapping subproblems_. It uses _memoization_ to avoid duplicating work.
- <<dynamic-programming-chap>>: a technique for speeding up recursive algorithms when there are many _overlapping subproblems_. It uses _memoization_ to avoid duplicating work.
- <<Divide and Conquer>>: _divide_ problems into smaller pieces, _conquer_ each subproblem, and then _join_ the results.
- <<Backtracking>>: search _all (or some)_ possible paths. However, it stops and _go back_ as soon as notice the current solution is not working.
- _Brute Force_: generate all possible solutions and tries all of them. (Use it as a last resort or as the starting point and to later optimize it).
Expand Down

AltStyle によって変換されたページ (->オリジナル) /