From d1688df5ed14aad3f3f1e173cbae403d30ec9c8b Mon Sep 17 00:00:00 2001 From: Jim Poulakos Date: Tue, 31 Oct 2017 10:09:45 -0500 Subject: [PATCH 001/151] docs: fix grammatical errors (#83) * docs: fix grammatical errors * Update README.md --- README.md | 4 ++-- preparing/cheatsheet.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a63fddab..2c6f92c8 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ This handbook is pretty new and help from you in contributing content would be v ## Why do I want this? -This repository has *practical* content that covers all phases of a technical interview; from applying for a job to passing the interviews to offer negotiation. Technically competent candidates might still find the non-technical content helpful as well. +This repository has *practical* content that covers all phases of a technical interview, from applying for a job to passing the interviews to offer negotiation. Technically competent candidates might still find the non-technical content helpful as well. ## Who is this for? @@ -38,7 +38,7 @@ Anybody who wants to land a job at a tech company but is new to technical interv There are so many awesome books like [Cracking the Coding Interview](http://www.crackingthecodinginterview.com/) and interview-related repositories out there on GitHub, what makes this repository different? The difference is that many existing interview repositories contain mainly links to external resources whereas this repository contains top quality curated content directly for your consumption. -Also, existing resources focus mainly on algorithm questions and lack in coverage for more domain-specific and non-technical questions. This handbook aims to cover content beyond the typical algorithmic coding questions. 😎 +Also, existing resources focus mainly on algorithm questions and lack coverage for more domain-specific and non-technical questions. This handbook aims to cover content beyond the typical algorithmic coding questions. 😎 ## Contents diff --git a/preparing/cheatsheet.md b/preparing/cheatsheet.md index c750f0ff..5d2f8ff6 100644 --- a/preparing/cheatsheet.md +++ b/preparing/cheatsheet.md @@ -1,7 +1,7 @@ Interview Cheatsheet == -This is a straight-to-the-point distilled list of technical interview Do's and Don'ts, mainly for algorithmic interviews. Some of these may apply to only phone screens on whiteboard interviews but most will apply to both. I revise this list before each of my interviews to remind myself of them and eventually internalized all of them to the point I do not have to rely on it anymore. +This is a straight-to-the-point, distilled list of technical interview Do's and Don'ts, mainly for algorithmic interviews. Some of these may apply to only phone screens or whiteboard interviews, but most will apply to both. I revise this list before each of my interviews to remind myself of them and eventually internalized all of them to the point I do not have to rely on it anymore. For a detailed walkthrough of interview preparation, refer to the ["Preparing for a Coding Interview"](./) section. @@ -30,7 +30,7 @@ For a detailed walkthrough of interview preparation, refer to the ["Preparing fo |✅|Introduce yourself in a few sentences under a minute or two.| |✅|Mention interesting points that are relevant to the role you are applying for.| |✅|Sound enthusiastic! Speak with a smile and you will naturally sound more engaging.| -|❌|Spend too long introducing yourself. The more time you spend talk the less time you have to code.| +|❌|Spend too long introducing yourself. The more time you spend talking the less time you have to code.| ### 3. Upon Getting the Question From d176b39d23e6ed135bce309160f25c84d9d1c042 Mon Sep 17 00:00:00 2001 From: Joe Riggs Date: Tue, 14 Nov 2017 09:26:32 -0500 Subject: [PATCH 002/151] Fix typo (#85) --- algorithms/bit-manipulation.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/algorithms/bit-manipulation.md b/algorithms/bit-manipulation.md index 5ad2f2c4..76aa4153 100644 --- a/algorithms/bit-manipulation.md +++ b/algorithms/bit-manipulation.md @@ -2,6 +2,6 @@ Bit Manipulation == - How do you verify if an interger is a power of 2? -- Wirte a program to print the binary representation of an integer. +- Write a program to print the binary representation of an integer. - Write a program to print out the number of 1 bits in a given integer. -- Write a program to determine the largest possible integer using the same number of 1 bits in a given number. \ No newline at end of file +- Write a program to determine the largest possible integer using the same number of 1 bits in a given number. From 75ebbaa0338ee252a95d070017d1b53948873a9e Mon Sep 17 00:00:00 2001 From: Nicholas Lee Date: Thu, 16 Nov 2017 10:53:31 +0900 Subject: [PATCH 003/151] Fix list mark (#86) --- front-end/interview-questions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front-end/interview-questions.md b/front-end/interview-questions.md index bded37d5..a3f1f52a 100644 --- a/front-end/interview-questions.md +++ b/front-end/interview-questions.md @@ -508,7 +508,7 @@ I shall throw in a comparison with `block` for good measure. | Margins and paddings | All sides respected. | All sides respected. | Only horizontal sides respected. Vertical sides, if specified, do not affect layout. Vertical space it takes up depends on `line-height`, even though the `border` and `padding` appear visually around the content. | | Float | - | - | Becomes like a `block` element where you can set vertical margins and paddings. | -**What's the difference between a `relative`, `fixed`, `absolute` and `static`-ally positioned element?** +### What's the difference between a `relative`, `fixed`, `absolute` and `static`-ally positioned element?** A positioned element is an element whose computed `position` property is either `relative`, `absolute`, `fixed` or `sticky`. From b6e8283908f480af40b66329cfe2b6252bc9fac2 Mon Sep 17 00:00:00 2001 From: Nicholas Lee Date: Fri, 17 Nov 2017 12:16:47 +0900 Subject: [PATCH 004/151] Fix typo (#88) typo --- front-end/interview-questions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front-end/interview-questions.md b/front-end/interview-questions.md index a3f1f52a..bb648a0d 100644 --- a/front-end/interview-questions.md +++ b/front-end/interview-questions.md @@ -879,7 +879,7 @@ This is a browser-reported string that allows the network protocol peers to iden ### Explain Ajax in as much detail as possible. -Ajax (asynchronous JavaScript and XML") is a set of web development techniques using many web technologies on the client side to create asynchronous web applications. With Ajax, web applications can send data to and retrieve from a server asynchronously (in the background) without interfering with the display and behavior of the existing page. By decoupling the data interchange layer from the presentation layer, Ajax allows for web pages, and by extension web applications, to change content dynamically without the need to reload the entire page. In practice, modern implementations commonly substitute JSON for XML due to the advantages of being native to JavaScript. +Ajax (asynchronous JavaScript and XML) is a set of web development techniques using many web technologies on the client side to create asynchronous web applications. With Ajax, web applications can send data to and retrieve from a server asynchronously (in the background) without interfering with the display and behavior of the existing page. By decoupling the data interchange layer from the presentation layer, Ajax allows for web pages, and by extension web applications, to change content dynamically without the need to reload the entire page. In practice, modern implementations commonly substitute JSON for XML due to the advantages of being native to JavaScript. The `XMLHttpRequest` API is frequently used for the asynchronous communication or these days, the `fetch` API. From 9d74d2b83690bec5ab76329bc7a4772e23e3f481 Mon Sep 17 00:00:00 2001 From: Tay Yang Shun Date: Sun, 19 Nov 2017 23:20:01 -0800 Subject: [PATCH 005/151] Add interview questions --- algorithms/array.md | 2 +- questions/01-histogram-stars.md | 37 ++++++++++++ questions/02-matrix-islands.md | 56 +++++++++++++++++++ questions/03-k-smallest-two-sorted.md | 40 +++++++++++++ questions/04-synonyms.md | 36 ++++++++++++ .../05-longest-consecutive-set-of-numbers.md | 33 +++++++++++ questions/06-string-compression.md | 25 +++++++++ questions/07-biggest-number-after-swap.md | 21 +++++++ questions/08-pivot-index.md | 19 +++++++ questions/09-move-zeroes.md | 18 ++++++ 10 files changed, 286 insertions(+), 1 deletion(-) create mode 100644 questions/01-histogram-stars.md create mode 100644 questions/02-matrix-islands.md create mode 100644 questions/03-k-smallest-two-sorted.md create mode 100644 questions/04-synonyms.md create mode 100644 questions/05-longest-consecutive-set-of-numbers.md create mode 100644 questions/06-string-compression.md create mode 100644 questions/07-biggest-number-after-swap.md create mode 100644 questions/08-pivot-index.md create mode 100644 questions/09-move-zeroes.md diff --git a/algorithms/array.md b/algorithms/array.md index 4027cfaa..0de9fedc 100644 --- a/algorithms/array.md +++ b/algorithms/array.md @@ -7,7 +7,7 @@ Arrays - Paginate an array with constraints, such as skipping certain items. - Implement a circular buffer using an array. - Given array of arrays, sort them in ascending order. -- Given an array of integers, print out a histogram of using said array; include a base layer (all stars) +- Given an array of integers, print out a histogram using the said array; include a base layer (all stars) - E.g. `[5, 4, 0, 3, 4, 1]` ``` diff --git a/questions/01-histogram-stars.md b/questions/01-histogram-stars.md new file mode 100644 index 00000000..766a2feb --- /dev/null +++ b/questions/01-histogram-stars.md @@ -0,0 +1,37 @@ +--- +id: 1 +title: Histogram Stars +topics: [array] +difficulty: easy +--- + +## Question + +``` +''' +Given an array of integers, print out a histogram using the array. Include a base layer (all stars) + +[5, 4, 0, 3, 4, 1] will result in the following: + +****** +***** +* +**** +***** +** +''' +``` + +## Follow Up + +``` +Print out a vertical version of the histogram. + +* +** * +** ** +** ** +** *** +****** +''' +``` diff --git a/questions/02-matrix-islands.md b/questions/02-matrix-islands.md new file mode 100644 index 00000000..26b3ed06 --- /dev/null +++ b/questions/02-matrix-islands.md @@ -0,0 +1,56 @@ +--- +id: 2 +title: Matrix Islands +topics: [array, depth-first-search, matrix] +difficulty: easy +source: + - https://leetcode.com/problems/number-of-islands/ + - https://leetcode.com/problems/max-area-of-island/ + - https://leetcode.com/problems/number-of-distinct-islands/ +--- + +## Question + +``` +''' +Given a matrix of 0s and 1s, count the number of islands present. + +[[0,0,1], + [0,0,0], + [0,1,1]] + +Answer: 2 +''' +``` + +## Follow Up + +``` +Given a matrix of 0s and 1s, find the size of the largest island present. + +''' +[[0,0,1], + [0,0,0], + [0,1,1]] + +Answer: 2 +``` + +## Follow Up II + +``` +Given a matrix of 0s and 1s, find the number of unique islands present present. + +''' +[[1,0,1,0], + [1,0,0,0], + [0,1,1,0]] + +Answer: 3 + +[[1,1,0,1], + [0,0,0,0], + [0,1,1,0]] + +Answer: 2 +``` diff --git a/questions/03-k-smallest-two-sorted.md b/questions/03-k-smallest-two-sorted.md new file mode 100644 index 00000000..1eaf3037 --- /dev/null +++ b/questions/03-k-smallest-two-sorted.md @@ -0,0 +1,40 @@ +--- +id: 3 +title: K Smallest Elements from Two Sorted Arrays +topics: [array] +difficulty: easy +--- + +## Question + +``` +''' +Find the k smallest elements from two sorted arrays of integers. + +Input: [1, 2, 3, 4, 5], [2, 3, 4], k = 3 +Output: [1, 2, 2] +''' +``` + +## Time Complexities + +- Bad: + - Time: O((n + m)log(n + m)) +- Good: + - Time: O(k) + +## Sample Answers + +```py +def k_smallest(A, B, k): + res = [] + a = b = 0 + while a < len(A) and b < len(B) and (a + b) < k: + if A[a] < B[b]: + res.append(A[a]) + a += 1 + else: + res.append(B[b]) + b += 1 + return res + A[a:k - b] + B[b:k - a] +``` diff --git a/questions/04-synonyms.md b/questions/04-synonyms.md new file mode 100644 index 00000000..b3615d76 --- /dev/null +++ b/questions/04-synonyms.md @@ -0,0 +1,36 @@ +--- +id: 4 +title: Synonyms +topics: [graph] +difficulty: medium +--- + +## Question + +``` +''' +Given a list of synonym pairs, determine if two words are synonymous. +Synonyms have a symmetric and transitive relation. i.e. if a <-> b and b <-> c, a <-> c. + +Input: +[["computer", "laptop"]] +"computer" +"laptop" + +Output: true + +Input: +[["computer", "laptop"], ["laptop", "pc"]] +"computer" +"pc" + +Output: true + +Input: +[["computer", "laptop"], ["laptop", "pc"], ["tablet", "iPad"]] +"computer" +"iPad" + +Output: false +''' +``` diff --git a/questions/05-longest-consecutive-set-of-numbers.md b/questions/05-longest-consecutive-set-of-numbers.md new file mode 100644 index 00000000..2231f8b3 --- /dev/null +++ b/questions/05-longest-consecutive-set-of-numbers.md @@ -0,0 +1,33 @@ +--- +id: 5 +title: Longest Consecutive Set of Numbers +topics: [graph] +difficulty: hard +source: https://leetcode.com/problems/longest-consecutive-sequence/ +--- + +## Question + +``` +''' +Given an array of integers, find the size of the largest set of consecutive numbers present in the array. + +Input: [100, 4, 200, 1, 3, 2] +Output: 4 because {1, 2, 3, 4} +''' +``` + +## Sample Answers + +```py +def longest_consecutive(nums): + nums = set(nums) + best = 0 + for x in nums: + if x - 1 not in nums: + y = x + 1 + while y in nums: + y += 1 + best = max(best, y - x) + return best +``` diff --git a/questions/06-string-compression.md b/questions/06-string-compression.md new file mode 100644 index 00000000..60b6a227 --- /dev/null +++ b/questions/06-string-compression.md @@ -0,0 +1,25 @@ +--- +id: 6 +title: String Compression and Decompression +topics: [string] +difficulty: easy +--- + +## Question + +``` +''' +Given a string, compress it by grouping repeated characters. The length after +compression must always be smaller than or equal to the original string. + +'aaabbccc' => 'a3b2c3' +''' +``` + +``` +''' +Given the above compressed string, decompress to obtain the original string. + +'a3b2c3' => 'aaabbccc' +''' +``` diff --git a/questions/07-biggest-number-after-swap.md b/questions/07-biggest-number-after-swap.md new file mode 100644 index 00000000..2f43f22f --- /dev/null +++ b/questions/07-biggest-number-after-swap.md @@ -0,0 +1,21 @@ +--- +id: 7 +title: Biggest Number After Swap +topics: [math] +difficulty: medium +source: https://leetcode.com/problems/maximum-swap/ +--- + +## Question + +``` +''' +Given a non-negative integer, find the maximum possible number if you can swap two digits at most once. + +2736 => 7236 +''' +``` + +## Follow Up + +- What if the given integer can be negative? diff --git a/questions/08-pivot-index.md b/questions/08-pivot-index.md new file mode 100644 index 00000000..81e978c9 --- /dev/null +++ b/questions/08-pivot-index.md @@ -0,0 +1,19 @@ +--- +id: 8 +title: Pivot Index +topics: [array] +difficulty: easy +source: https://leetcode.com/problems/find-pivot-index/ +--- + +## Question + +``` +''' +Given an array of integers, return the pivot index of this array. + +A pivot index is the index where the sum of the numbers to its left is equal to the sum of the numbers to its right: + +[7, 2, 3, 4] => 1 +''' +``` diff --git a/questions/09-move-zeroes.md b/questions/09-move-zeroes.md new file mode 100644 index 00000000..e8f9556f --- /dev/null +++ b/questions/09-move-zeroes.md @@ -0,0 +1,18 @@ +--- +id: 9 +title: Move Zeroes +topics: [array] +difficulty: easy +source: https://leetcode.com/problems/move-zeroes/ +--- + +## Question + +``` +''' +Given an array of integers, write a function to move all zeroes to the end of it while +maintaining the relative order of the non-zero elements. + +[0, 1, 0, 3, 12] => [1, 3, 12, 0, 0]. +''' +``` From 7247dbcaf7ebce57f277e478855e519962cb452d Mon Sep 17 00:00:00 2001 From: Nicholas Lee Date: Fri, 24 Nov 2017 12:37:14 +0900 Subject: [PATCH 006/151] Improve answer for enumerating through JS object properties (#91) I think it is necessary to mention the way to iterating over all non-enumerable properties --- front-end/interview-questions.md | 1 + 1 file changed, 1 insertion(+) diff --git a/front-end/interview-questions.md b/front-end/interview-questions.md index bb648a0d..77ce907f 100644 --- a/front-end/interview-questions.md +++ b/front-end/interview-questions.md @@ -1240,6 +1240,7 @@ For objects: - `for` loops - `for (var property in obj) { console.log(property); }`. However, this will also iterate through its inherited properties, and you will add an `obj.hasOwnProperty(property)` check before using it. - `Object.keys()` - `Object.keys(obj).forEach(function (property) { ... })`. `Object.keys()` is a static method that will lists all enumerable properties of the object that you pass it. +- `Object.getOwnPropertyNames()` - `Object.getOwnPropertyNames(obj).forEach(function (property) { ... })`. `Object.getOwnPropertyNames()` is a static method that will lists all enumerable and non-enumerable properties of the object that you pass it. For arrays: From b92118eb3189e23cfbb0a7c947e3963292cad9a3 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Mon, 25 Dec 2017 13:00:22 -0800 Subject: [PATCH 007/151] Remove questions --- questions/01-histogram-stars.md | 37 ------------ questions/02-matrix-islands.md | 56 ------------------- questions/03-k-smallest-two-sorted.md | 40 ------------- questions/04-synonyms.md | 36 ------------ .../05-longest-consecutive-set-of-numbers.md | 33 ----------- questions/06-string-compression.md | 25 --------- questions/07-biggest-number-after-swap.md | 21 ------- questions/08-pivot-index.md | 19 ------- questions/09-move-zeroes.md | 18 ------ 9 files changed, 285 deletions(-) delete mode 100644 questions/01-histogram-stars.md delete mode 100644 questions/02-matrix-islands.md delete mode 100644 questions/03-k-smallest-two-sorted.md delete mode 100644 questions/04-synonyms.md delete mode 100644 questions/05-longest-consecutive-set-of-numbers.md delete mode 100644 questions/06-string-compression.md delete mode 100644 questions/07-biggest-number-after-swap.md delete mode 100644 questions/08-pivot-index.md delete mode 100644 questions/09-move-zeroes.md diff --git a/questions/01-histogram-stars.md b/questions/01-histogram-stars.md deleted file mode 100644 index 766a2feb..00000000 --- a/questions/01-histogram-stars.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -id: 1 -title: Histogram Stars -topics: [array] -difficulty: easy ---- - -## Question - -``` -''' -Given an array of integers, print out a histogram using the array. Include a base layer (all stars) - -[5, 4, 0, 3, 4, 1] will result in the following: - -****** -***** -* -**** -***** -** -''' -``` - -## Follow Up - -``` -Print out a vertical version of the histogram. - -* -** * -** ** -** ** -** *** -****** -''' -``` diff --git a/questions/02-matrix-islands.md b/questions/02-matrix-islands.md deleted file mode 100644 index 26b3ed06..00000000 --- a/questions/02-matrix-islands.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -id: 2 -title: Matrix Islands -topics: [array, depth-first-search, matrix] -difficulty: easy -source: - - https://leetcode.com/problems/number-of-islands/ - - https://leetcode.com/problems/max-area-of-island/ - - https://leetcode.com/problems/number-of-distinct-islands/ ---- - -## Question - -``` -''' -Given a matrix of 0s and 1s, count the number of islands present. - -[[0,0,1], - [0,0,0], - [0,1,1]] - -Answer: 2 -''' -``` - -## Follow Up - -``` -Given a matrix of 0s and 1s, find the size of the largest island present. - -''' -[[0,0,1], - [0,0,0], - [0,1,1]] - -Answer: 2 -``` - -## Follow Up II - -``` -Given a matrix of 0s and 1s, find the number of unique islands present present. - -''' -[[1,0,1,0], - [1,0,0,0], - [0,1,1,0]] - -Answer: 3 - -[[1,1,0,1], - [0,0,0,0], - [0,1,1,0]] - -Answer: 2 -``` diff --git a/questions/03-k-smallest-two-sorted.md b/questions/03-k-smallest-two-sorted.md deleted file mode 100644 index 1eaf3037..00000000 --- a/questions/03-k-smallest-two-sorted.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -id: 3 -title: K Smallest Elements from Two Sorted Arrays -topics: [array] -difficulty: easy ---- - -## Question - -``` -''' -Find the k smallest elements from two sorted arrays of integers. - -Input: [1, 2, 3, 4, 5], [2, 3, 4], k = 3 -Output: [1, 2, 2] -''' -``` - -## Time Complexities - -- Bad: - - Time: O((n + m)log(n + m)) -- Good: - - Time: O(k) - -## Sample Answers - -```py -def k_smallest(A, B, k): - res = [] - a = b = 0 - while a < len(A) and b < len(B) and (a + b) < k: - if A[a] < B[b]: - res.append(A[a]) - a += 1 - else: - res.append(B[b]) - b += 1 - return res + A[a:k - b] + B[b:k - a] -``` diff --git a/questions/04-synonyms.md b/questions/04-synonyms.md deleted file mode 100644 index b3615d76..00000000 --- a/questions/04-synonyms.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -id: 4 -title: Synonyms -topics: [graph] -difficulty: medium ---- - -## Question - -``` -''' -Given a list of synonym pairs, determine if two words are synonymous. -Synonyms have a symmetric and transitive relation. i.e. if a <-> b and b <-> c, a <-> c. - -Input: -[["computer", "laptop"]] -"computer" -"laptop" - -Output: true - -Input: -[["computer", "laptop"], ["laptop", "pc"]] -"computer" -"pc" - -Output: true - -Input: -[["computer", "laptop"], ["laptop", "pc"], ["tablet", "iPad"]] -"computer" -"iPad" - -Output: false -''' -``` diff --git a/questions/05-longest-consecutive-set-of-numbers.md b/questions/05-longest-consecutive-set-of-numbers.md deleted file mode 100644 index 2231f8b3..00000000 --- a/questions/05-longest-consecutive-set-of-numbers.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -id: 5 -title: Longest Consecutive Set of Numbers -topics: [graph] -difficulty: hard -source: https://leetcode.com/problems/longest-consecutive-sequence/ ---- - -## Question - -``` -''' -Given an array of integers, find the size of the largest set of consecutive numbers present in the array. - -Input: [100, 4, 200, 1, 3, 2] -Output: 4 because {1, 2, 3, 4} -''' -``` - -## Sample Answers - -```py -def longest_consecutive(nums): - nums = set(nums) - best = 0 - for x in nums: - if x - 1 not in nums: - y = x + 1 - while y in nums: - y += 1 - best = max(best, y - x) - return best -``` diff --git a/questions/06-string-compression.md b/questions/06-string-compression.md deleted file mode 100644 index 60b6a227..00000000 --- a/questions/06-string-compression.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -id: 6 -title: String Compression and Decompression -topics: [string] -difficulty: easy ---- - -## Question - -``` -''' -Given a string, compress it by grouping repeated characters. The length after -compression must always be smaller than or equal to the original string. - -'aaabbccc' => 'a3b2c3' -''' -``` - -``` -''' -Given the above compressed string, decompress to obtain the original string. - -'a3b2c3' => 'aaabbccc' -''' -``` diff --git a/questions/07-biggest-number-after-swap.md b/questions/07-biggest-number-after-swap.md deleted file mode 100644 index 2f43f22f..00000000 --- a/questions/07-biggest-number-after-swap.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -id: 7 -title: Biggest Number After Swap -topics: [math] -difficulty: medium -source: https://leetcode.com/problems/maximum-swap/ ---- - -## Question - -``` -''' -Given a non-negative integer, find the maximum possible number if you can swap two digits at most once. - -2736 => 7236 -''' -``` - -## Follow Up - -- What if the given integer can be negative? diff --git a/questions/08-pivot-index.md b/questions/08-pivot-index.md deleted file mode 100644 index 81e978c9..00000000 --- a/questions/08-pivot-index.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -id: 8 -title: Pivot Index -topics: [array] -difficulty: easy -source: https://leetcode.com/problems/find-pivot-index/ ---- - -## Question - -``` -''' -Given an array of integers, return the pivot index of this array. - -A pivot index is the index where the sum of the numbers to its left is equal to the sum of the numbers to its right: - -[7, 2, 3, 4] => 1 -''' -``` diff --git a/questions/09-move-zeroes.md b/questions/09-move-zeroes.md deleted file mode 100644 index e8f9556f..00000000 --- a/questions/09-move-zeroes.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -id: 9 -title: Move Zeroes -topics: [array] -difficulty: easy -source: https://leetcode.com/problems/move-zeroes/ ---- - -## Question - -``` -''' -Given an array of integers, write a function to move all zeroes to the end of it while -maintaining the relative order of the non-zero elements. - -[0, 1, 0, 3, 12] => [1, 3, 12, 0, 0]. -''' -``` From 770bb523da5225f66fa532c80021762ed5cd4426 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Mon, 25 Dec 2017 13:10:39 -0800 Subject: [PATCH 008/151] Mention Grokking the System Design Interview and Coderust --- design/README.md | 1 + preparing/README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/design/README.md b/design/README.md index 7cdbc88e..08004f55 100644 --- a/design/README.md +++ b/design/README.md @@ -3,6 +3,7 @@ Design Questions ## Guides +- [Grokking the System Design Interview](https://www.educative.io/collection/5668639101419520/5649050225344512) - https://github.com/donnemartin/system-design-primer - https://github.com/checkcheckzz/system-design-interview - https://github.com/shashank88/system_design diff --git a/preparing/README.md b/preparing/README.md index 58cb14b4..80776abc 100644 --- a/preparing/README.md +++ b/preparing/README.md @@ -27,7 +27,7 @@ If you are interested in how data structures are implemented, check out [Lago](h Next, gain familiarity and mastery of the algorithms and data structures in your chosen programming language: -1. Practice coding algorithms using your chosen language. While [Cracking the Coding Interview](http://www.crackingthecodinginterview.com/) is a good resource for practice, I prefer being able to type code, run it and get instant feedback. There are various Online Judges such as [LeetCode](https://leetcode.com/), [HackerRank](https://www.hackerrank.com/) and [CodeForces](http://codeforces.com/) for you to practice questions online and get used to the language. From experience, LeetCode questions are the most similar to the kind of questions being asked in interviews whereas HackerRank and CodeForces questions are more similar to competitive programming questions. If you practice enough LeetCode questions, there is a good chance that you would have seen/done your actual interview question (or some variant) on LeetCode before. +1. Practice coding algorithms using your chosen language. While [Cracking the Coding Interview](http://www.crackingthecodinginterview.com/) is a good resource for practice, I prefer being able to type code, run it and get instant feedback. There are various Online Judges such as [LeetCode](https://leetcode.com/), [HackerRank](https://www.hackerrank.com/) and [CodeForces](http://codeforces.com/) for you to practice questions online and get used to the language. From experience, LeetCode questions are the most similar to the kind of questions being asked in interviews whereas HackerRank and CodeForces questions are more similar to competitive programming questions. If you practice enough LeetCode questions, there is a good chance that you would have seen/done your actual interview question (or some variant) on LeetCode before. If you are more of a visual person, [Coderust](https://www.educative.io/collection/5642554087309312/5679846214598656) explains the common algorithm questions through step-by-step visualizations which makes understanding the solutions much easier. 2. Learn and understand the time and space complexities of the common operations in your chosen language. For Python, this [page](https://wiki.python.org/moin/TimeComplexity) will come in handy. Also find out the underlying sorting algorithm that is being used in the language's `sort()` function and its time and space complexity (in Python its Timsort which is a hybrid sort). After completing a question on LeetCode, I usually add the time and space complexities of the written code as comments above the function body to remind myself to analyze the algorithm after I am done with the implementation. 3. Read up on the recommended coding style for your language and stick to it. If you have chosen Python, refer to the PEP 8 Style Guide. If you have chosen Java, refer to Google's Java Style Guide. 4. Find out and be familiar with the common pitfalls and caveats of the language. If you point out them out during the interview and intelligently avoid falling into them, you will usually impress the interviewer and that results in bonus points in your feedback, regardless of whether the interviewer is familiar with the language or not. From 8396d8e2ca73aea87ed7aeff35ffb76c3d566374 Mon Sep 17 00:00:00 2001 From: Nicholette Li Date: Fri, 5 Jan 2018 12:13:59 +0800 Subject: [PATCH 009/151] Fix typo in Front End Interview questions (#95) --- front-end/interview-questions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/front-end/interview-questions.md b/front-end/interview-questions.md index 77ce907f..ad68ee0e 100644 --- a/front-end/interview-questions.md +++ b/front-end/interview-questions.md @@ -938,13 +938,13 @@ These days, [CORS](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) i ### Have you ever used JavaScript templating? If so, what libraries have you used? -Yes. Handlebars, Underscore, Lodash, AngularJS and JSX. I disliked templating in AngularJS because it made heavy use of strings in the directives and typos would go uncaught. JSX is my new favourite as it is closer to JavaScript and there is barely and syntax to be learnt. Nowadays, you can even use ES2015 template string literals as a quick way for creating templates without relying on third-party code. +Yes. Handlebars, Underscore, Lodash, AngularJS and JSX. I disliked templating in AngularJS because it made heavy use of strings in the directives and typos would go uncaught. JSX is my new favourite as it is closer to JavaScript and there is barely any syntax to learn. Nowadays, you can even use ES2015 template string literals as a quick way for creating templates without relying on third-party code. ```js const template = `
My name is: ${name}
`; ``` -However, do beware of a potential XSS in the above approach as the contents are not escaped for you, unlike in templating libraries. +However, do be aware of a potential XSS in the above approach as the contents are not escaped for you, unlike in templating libraries. ### Explain "hoisting". From 4cb656f12dfaa42ea6a9dd61c1f47b133484500c Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Thu, 11 Jan 2018 22:02:31 -0800 Subject: [PATCH 010/151] Update dom.md --- front-end/dom.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front-end/dom.md b/front-end/dom.md index b0830e8f..e6671939 100644 --- a/front-end/dom.md +++ b/front-end/dom.md @@ -86,7 +86,7 @@ A `NodeList` can contain any node type, but an `HTMLCollection` is supposed to o **How do you convert an `HTMLCollection` or `NodeList` into an array?** -``` +```js const nodelist = document.querySelectorAll('div'); // Array.from const divArray = Array.from(nodelist); From eacab7ff2c4340a25e3ad3dfc9849e1e0a85fc72 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Sat, 13 Jan 2018 12:21:03 -0800 Subject: [PATCH 011/151] Mention about moving out front end content --- README.md | 55 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 2c6f92c8..3a0d95ef 100644 --- a/README.md +++ b/README.md @@ -15,20 +15,20 @@ Carefully curated content to help you ace your next technical interview, with a focus on algorithms and the front end domain. System design questions are in-progress. Besides the usual algorithm questions, other **awesome** stuff includes: -- [How to prepare](preparing) for coding interviews -- [Interview Cheatsheet](preparing/cheatsheet.md) - Straight-to-the-point Do's and Don'ts 🆕 -- [Algorithm tips and the best practice questions](algorithms) categorized by topic -- ["Front-end Job Interview Questions" answers](front-end/interview-questions.md) -- [Interview formats](non-technical/interview-formats.md) of the top tech companies -- [Behavioral questions](non-technical/behavioral.md) categorized by companies -- [Good questions to ask your interviewers](non-technical/questions-to-ask.md) at the end of the interviews -- [Helpful resume tips](non-technical/resume.md) to get your resume noticed and the Do's and Don'ts +* [How to prepare](preparing) for coding interviews +* [Interview Cheatsheet](preparing/cheatsheet.md) - Straight-to-the-point Do's and Don'ts 🆕 +* [Algorithm tips and the best practice questions](algorithms) categorized by topic +* ["Front-end Job Interview Questions" answers](https://github.com/yangshun/front-end-interview-handbook) +* [Interview formats](non-technical/interview-formats.md) of the top tech companies +* [Behavioral questions](non-technical/behavioral.md) categorized by companies +* [Good questions to ask your interviewers](non-technical/questions-to-ask.md) at the end of the interviews +* [Helpful resume tips](non-technical/resume.md) to get your resume noticed and the Do's and Don'ts This handbook is pretty new and help from you in contributing content would be very much appreciated! ## Why do I want this? -This repository has *practical* content that covers all phases of a technical interview, from applying for a job to passing the interviews to offer negotiation. Technically competent candidates might still find the non-technical content helpful as well. +This repository has _practical_ content that covers all phases of a technical interview, from applying for a job to passing the interviews to offer negotiation. Technically competent candidates might still find the non-technical content helpful as well. ## Who is this for? @@ -40,23 +40,26 @@ There are so many awesome books like [Cracking the Coding Interview](http://www. Also, existing resources focus mainly on algorithm questions and lack coverage for more domain-specific and non-technical questions. This handbook aims to cover content beyond the typical algorithmic coding questions. 😎 +## Looking for Front End content? + +Front end-related content have been extract out into a separate repository - [Front End Interview Handbook](https://github.com/yangshun/front-end-interview-handbook). + ## Contents -- **[Preparing for a Coding Interview](preparing)** - - [Interview cheatsheet](preparing/cheatsheet.md) - Straight-to-the-point Do's and Don'ts -- **[Algorithm Questions](algorithms)** - Questions categorized by topics -- **[Design Questions](design)** -- **[Front-end Study Notes](front-end)** - Summarized notes on the various aspects of front-end - - [Front-end Job Interview Questions and Answers](front-end/interview-questions.md) 🔥⭐ -- **[Non-Technical Tips](non-technical)** - Random non-technical tips that cover behavioral and psychological aspects, interview formats and "Do you have any questions for me?" - - [Resume Tips](non-technical/resume.md) - - [Behavioral Questions](non-technical/behavioral.md) - - [Interview Formats](non-technical/interview-formats.md) - - [Psychological Tricks](non-technical/psychological-tricks.md) - - [Questions to Ask](non-technical/questions-to-ask.md) - - [Negotiation Tips](non-technical/negotiation.md) -- **[Utilities](utilities)** - Snippets of algorithms/code that will help in coding questions - - **UPDATE** - Check out [Lago](https://github.com/yangshun/lago), which is a Data Structures and Algorithms library that contains more high-quality implementations with 100% test coverage. +* **[Preparing for a Coding Interview](preparing)** + * [Interview cheatsheet](preparing/cheatsheet.md) - Straight-to-the-point Do's and Don'ts +* **[Algorithm Questions](algorithms)** - Questions categorized by topics +* **[Design Questions](design)** +* **[Front-end Job Interview Questions and Answers](https://github.com/yangshun/front-end-interview-handbook) 🔥⭐** - Answers to the famous Front End Developer Job Interview questions +* **[Non-Technical Tips](non-technical)** - Random non-technical tips that cover behavioral and psychological aspects, interview formats and "Do you have any questions for me?" + * [Resume Tips](non-technical/resume.md) + * [Behavioral Questions](non-technical/behavioral.md) + * [Interview Formats](non-technical/interview-formats.md) + * [Psychological Tricks](non-technical/psychological-tricks.md) + * [Questions to Ask](non-technical/questions-to-ask.md) + * [Negotiation Tips](non-technical/negotiation.md) +* **[Utilities](utilities)** - Snippets of algorithms/code that will help in coding questions + * **UPDATE** - Check out [Lago](https://github.com/yangshun/lago), which is a Data Structures and Algorithms library that contains more high-quality implementations with 100% test coverage. ## Related @@ -68,5 +71,5 @@ There are no formal contributing guidelines at the moment as things are still in ## Maintainers -- [Yangshun Tay](https://github.com/yangshun) -- [Louie Tan](https://github.com/louietyj) +* [Yangshun Tay](https://github.com/yangshun) +* [Louie Tan](https://github.com/louietyj) From c34b341a366d38320673f943d15a4997f24bb844 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Mon, 15 Jan 2018 11:43:02 -0800 Subject: [PATCH 012/151] Tweak wording --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3a0d95ef..88338e62 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ ## What is this? -Carefully curated content to help you ace your next technical interview, with a focus on algorithms and the front end domain. System design questions are in-progress. Besides the usual algorithm questions, other **awesome** stuff includes: +Carefully curated content to help you ace your next technical interview, with a focus on algorithms. System design questions are in-progress. Besides the usual algorithm questions, other **awesome** stuff includes: * [How to prepare](preparing) for coding interviews * [Interview Cheatsheet](preparing/cheatsheet.md) - Straight-to-the-point Do's and Don'ts 🆕 @@ -42,7 +42,7 @@ Also, existing resources focus mainly on algorithm questions and lack coverage f ## Looking for Front End content? -Front end-related content have been extract out into a separate repository - [Front End Interview Handbook](https://github.com/yangshun/front-end-interview-handbook). +Front end-related content have been extracted out into a separate repository - [Front End Interview Handbook](https://github.com/yangshun/front-end-interview-handbook). ## Contents @@ -50,7 +50,7 @@ Front end-related content have been extract out into a separate repository - [Fr * [Interview cheatsheet](preparing/cheatsheet.md) - Straight-to-the-point Do's and Don'ts * **[Algorithm Questions](algorithms)** - Questions categorized by topics * **[Design Questions](design)** -* **[Front-end Job Interview Questions and Answers](https://github.com/yangshun/front-end-interview-handbook) 🔥⭐** - Answers to the famous Front End Developer Job Interview questions +* **[Front-end Job Interview Questions and Answers](https://github.com/yangshun/front-end-interview-handbook) 🔥⭐** - Answers to the famous "Front-end Job Interview Questions" * **[Non-Technical Tips](non-technical)** - Random non-technical tips that cover behavioral and psychological aspects, interview formats and "Do you have any questions for me?" * [Resume Tips](non-technical/resume.md) * [Behavioral Questions](non-technical/behavioral.md) From 264f6cf7d8284c2f8f4c6ed8e0f57e5a9bf959d3 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Wed, 17 Jan 2018 00:24:03 -0800 Subject: [PATCH 013/151] Remove Front End --- front-end/accessibility.md | 201 ----- front-end/browser.md | 59 -- front-end/caching.md | 14 - front-end/css.md | 34 - front-end/design.md | 14 - front-end/dom.md | 102 --- front-end/html.md | 18 - front-end/interview-questions.md | 1306 +----------------------------- front-end/javascript.md | 108 --- front-end/networking.md | 11 - front-end/performance.md | 66 -- front-end/security.md | 110 --- front-end/widgets.md | 56 -- 13 files changed, 2 insertions(+), 2097 deletions(-) delete mode 100644 front-end/accessibility.md delete mode 100644 front-end/browser.md delete mode 100644 front-end/caching.md delete mode 100644 front-end/css.md delete mode 100644 front-end/design.md delete mode 100644 front-end/dom.md delete mode 100644 front-end/html.md delete mode 100644 front-end/javascript.md delete mode 100644 front-end/networking.md delete mode 100644 front-end/performance.md delete mode 100644 front-end/security.md delete mode 100644 front-end/widgets.md diff --git a/front-end/accessibility.md b/front-end/accessibility.md deleted file mode 100644 index e6f61451..00000000 --- a/front-end/accessibility.md +++ /dev/null @@ -1,201 +0,0 @@ -Accessibility -== - -## Glossary - -- **Accessibility** - -- **WAI-ARIA** - Web Accessibility Initiative - Accessible Rich Internet Applications. Commonly shortened to ARIA. - -## What is Accessibility? - -Making sure that the content and the websites we create are usable to people with impairments or disabilities. - -## WebAIM Checklist - -The following is a checklist that contains recommendations for implementing HTML-related principles and techniques for those seeking WCAG 2.0 conformance (it is NOT the Web Content Accessibility Guidelines (WCAG) 2.0). - -- **Perceivable** - Web content is made available to the senses - sight, hearing, and/or touch. - - Text Alternatives: Provide text alternatives for any non-text content. - - Time-based Media: Provide alternatives for time-based media. - - Adaptable: Create content that can be presented in different ways (for example simpler layout) without losing information or structure. - - Distinguishable: Make it easier for users to see and hear content including separating foreground from background. -- **Operable** - Interface forms, controls, and navigation are operable. - - Keyboard Accessible: Make all functionality available from a keyboard. - - Enough Time: Provide users enough time to read and use content. - - Seizures: Do not design content in a way that is known to cause seizures. - - Navigable: Provide ways to help users navigate, find content, and determine where they are. -- **Understandable** - Content and interface are understandable. - - Readable: Make text content readable and understandable. - - Predictable: Make Web pages appear and operate in predictable ways. - - Input Assistance: Help users avoid and correct mistakes. -- **Robust** - Content can be used reliably by a wide variety of user agents, including assistive technologies. - - Compatible: Maximize compatibility with current and future user agents, including assistive technologies. - -**Source:** http://webaim.org/standards/wcag/checklist - -## Focus - -- Making sure your application has a sensible tab order is important. -- HTML forms and inputs are focusable and handle keyboard events by default. -- Focus tab order relies on the DOM order in the HTML. -- Be careful when using CSS when changing the order of elements on the screen, it can cause the order to be unintuitive and messy. -- `tabindex` attribute: - - `-1`: Not in the natural tab order, but programatically focusable using JavaScript with `focus()` method. Useful for off-screen content which later appears on screen. Children elements are **NOT** pulled out of the tab order. - - `0`: In the natural tab order and can be programatically focused. - - `1` (bigger than 1): In the natural tab order but jumped in front of the tab order regardless of where it is in the DOM. It can be considered an anti-pattern. -- Add focus behavior to interactive controls, like buttons, tabs, dropdowns, stuff that users will interactive with. -- Use skip links to allow users to skip directly to the main content without having to tab through all the navigation. -- `document.activeElement` is useful in tracking the current element that has focus on. - -## Semantics - -- Using proper labeling not only helps accessibility but it makes the element easier to target for all users! -- Use `