diff --git a/README.md b/README.md index b6057b73..2c6f92c8 100644 --- a/README.md +++ b/README.md @@ -16,42 +16,51 @@ 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/format.md) of the top tech companies +- [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 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? -Anybody who wants to land a job at a tech company but is new to technical interviews, or seasoned engineers who have not been on the other side of the interviewing table in a while and wants to get back into the game. +Anybody who wants to land a job at a tech company but is new to technical interviews, seasoned engineers who have not been on the other side of the interviewing table in a while and want to get back into the game, or anyone who wants to be better at technical interviewing. ## How is this repository different? 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 - **[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/format.md) - - [Psychological Tricks](non-technical/psychological.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. +- **[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 + +If you are interested in how data structures are implemented, check out [Lago](https://github.com/yangshun/lago), a Data Structures and Algorithms library for JavaScript. It is pretty much still WIP but I intend to make it into a library that is able to be used in production and also a reference resource for revising Data Structures and Algorithms. ## Contributing diff --git a/algorithms/README.md b/algorithms/README.md index 0ad01b24..abc4ca9e 100644 --- a/algorithms/README.md +++ b/algorithms/README.md @@ -5,6 +5,8 @@ This section dives deep into practical tips for specific topics of algorithms an For each topic, study links are recommended to help you master the topic. There is a list of recommended common questions to practice which in my opinion is highly valuable for mastering the core concepts for the topic. +If you are interested in how data structures are implemented, check out [Lago](https://github.com/yangshun/lago), a Data Structures and Algorithms library for JavaScript. It is pretty much still WIP but I intend to make it into a library that is able to be used in production and also a reference resource for revising Data Structures and Algorithms. + ## Contents - [Array](array.md) @@ -27,6 +29,8 @@ For each topic, study links are recommended to help you master the topic. There ## General Tips +Clarify any assumptions you made subconsciously. Many questions are under-specified on purpose. + Always validate input first. Check for invalid/empty/negative/different type input. Never assume you are given the valid parameters. Alternatively, clarify with the interviewer whether you can assume valid input (usually yes), which can save you time from writing code that does input validation. Are there any time/space complexity requirements/constraints? @@ -56,7 +60,7 @@ Data structures can be augmented to achieve efficient time complexities across d Hashmaps are probably the most commonly used data structure for algorithm questions. If you are stuck on a question, your last resort can be to enumerate through the possible data structures (thankfully there aren't that many of them) and consider whether each of them can be applied to the problem. This has worked for me sometimes. -If you are cutting corners in your code, state that out loud to your interviewer and say what you would do in a non-interview setting (no time constraints). E.g., I would write a regex to parse this string rather than using `split()` which does not cover all cases. +If you are cutting corners in your code, state that out loud to your interviewer and say what you would do in a non-interview setting (no time constraints). E.g., I would write a regex to parse this string rather than using `split()` which may not cover all cases. ## Sequence @@ -189,7 +193,7 @@ You can be given a list of edges and tasked to build your own graph from the edg - Adjacency list. - Hashmap of hashmaps. -Some inputs look like they are trees but they are actually graphs. In that case you will have to handle cycles and keep a set of visited nodes when traversing. +A tree-like diagram could very well be a graph that allows for cycles and a naive recursive solution would not work. In that case you will have to handle cycles and keep a set of visited nodes when traversing. #### Graph search algorithms: @@ -532,7 +536,7 @@ When a question involves a BST, the interviewer is usually looking for a solutio #### Study Links - [Trying to Understand Tries](https://medium.com/basecs/trying-to-understand-tries-3ec6bede0014) -- [Implement Trie (Prefix Tree)] +- [Implement Trie (Prefix Tree)](https://leetcode.com/articles/implement-trie-prefix-tree/) #### Notes diff --git a/algorithms/array.md b/algorithms/array.md index feadbedd..4027cfaa 100644 --- a/algorithms/array.md +++ b/algorithms/array.md @@ -1,7 +1,7 @@ Arrays == -- In an arrays of arrays, e.g. given `[[], [1, 2, 3], [4, 5], [], [], [6, 7], [8], [9, 10], [], []]`, print: `1, 2, 3, 4, 5, 6, 7, 8, 9, 10`. +- In an array of arrays, e.g. given `[[], [1, 2, 3], [4, 5], [], [], [6, 7], [8], [9, 10], [], []]`, print: `1, 2, 3, 4, 5, 6, 7, 8, 9, 10`. - Implement an iterator that supports `hasNext()`, `next()` and `remove()` methods. - Given a list of item prices, find all possible combinations of items that sum a particular value `K`. - Paginate an array with constraints, such as skipping certain items. @@ -56,3 +56,5 @@ Arrays - Given an array, return the length of the longest increasing contiguous subarray. - E.g., `[1, 3, 2, 3, 4, 8, 7, 9]`, should return `4` because the longest increasing array is `[2, 3, 4, 8]`. - [Source](http://blog.gainlo.co/index.php/2017/02/02/uber-interview-questions-longest-increasing-subarray/). +- Given an array of integers where every value appears twice except one, find the single, non-repeating value. Follow up: do so with O(1) space. + - E.g., `[2, 5, 3, 2, 1, 3, 4, 5, 1]` returns 4, because it is the only value that appears in the array only once. diff --git a/algorithms/bit-manipulation.md b/algorithms/bit-manipulation.md new file mode 100644 index 00000000..5ad2f2c4 --- /dev/null +++ b/algorithms/bit-manipulation.md @@ -0,0 +1,7 @@ +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 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 diff --git a/algorithms/dynamic-programming.md b/algorithms/dynamic-programming.md index be6979d6..978fa611 100644 --- a/algorithms/dynamic-programming.md +++ b/algorithms/dynamic-programming.md @@ -5,8 +5,8 @@ Dynamic Programming - Given some coin denominations and a target value `M`, return the coins combination with the minimum number of coins. - Time complexity: `O(MN)`, where N is the number of distinct type of coins. - Space complexity: `O(M)`. -- Given a set of numbers in an array which represent number of consecutive days of AirBnb reservation requested, as a host, pick the sequence which maximizes the number of days of occupancy, at the same time, leaving at least a 1 day gap in-between bookings for cleaning. - - Problem reduces to finding the maximum sum of non-consecutive array elements. +- Given a set of numbers in an array which represent a number of consecutive days of Airbnb reservation requested, as a host, pick the sequence which maximizes the number of days of occupancy, at the same time, leaving at least a 1-day gap in-between bookings for cleaning. + - The problem reduces to finding the maximum sum of non-consecutive array elements. - E.g. ~~~ // [5, 1, 1, 5] => 10 @@ -16,7 +16,8 @@ Dynamic Programming // Dec 6 - 7 // Dec 7 - 12 - The answer would be to pick Dec 1-5 (5 days) and then pick Dec 7-12 for a total of 10 days of occupancy, at the same time, leaving at least 1 day gap for cleaning between reservations. + The answer would be to pick Dec 1-5 (5 days) and then pick Dec 7-12 for a total of 10 days of + occupancy, at the same time, leaving at least 1-day gap for cleaning between reservations. Similarly, // [3, 6, 4] => 7 diff --git a/algorithms/linked-list.md b/algorithms/linked-list.md index 67cda73f..8dd1dbdd 100644 --- a/algorithms/linked-list.md +++ b/algorithms/linked-list.md @@ -10,4 +10,3 @@ Linked List - A question involving an API's integration with hash map where the buckets of hash map are made up of linked lists. - Given a singly linked list (a list which can only be traversed in one direction), find the item that is located at 'k' items from the end. So if the list is a, b, c, d and k is 2 then the answer is 'c'. The solution should not search the list twice. - How can you tell if a Linked List is a Palindrome? -- Implement a LRU cache with O(1) runtime for all its operations. diff --git a/algorithms/matrix.md b/algorithms/matrix.md index 6093c692..a0977e9e 100644 --- a/algorithms/matrix.md +++ b/algorithms/matrix.md @@ -3,7 +3,7 @@ Matrix - You're given a 3 x 3 board of a tile puzzle, with 8 tiles numbered 1 to 8, and an empty spot. You can move any tile adjacent to the empty spot, to the empty spot, creating an empty spot where the tile originally was. The goal is to find a series of moves that will solve the board, i.e. get `[[1, 2, 3], [4, 5, 6], [7, 8, - ]]` where - is the empty tile. - Boggle implementation. Given a dictionary, and a matrix of letters, find all the words in the matrix that are in the dictionary. You can go across, down or diagonally. -- The values of the matrix will represent numbers of carrots available to the rabbit in each square of the garden. If the garden does not have an exact center, the rabbit should start in the square closest to the center with the highest carrot count. On a given turn, the rabbit will eat the carrots available on the square that it is on, and then move up, down, left, or right, choosing the the square that has the most carrots. If there are no carrots left on any of the adjacent squares, the rabbit will go to sleep. You may assume that the rabbit will never have to choose between two squares with the same number of carrots. Write a function which takes a garden matrix and returns the number of carrots the rabbit eats. You may assume the matrix is rectangular with at least 1 row and 1 column, and that it is populated with non-negative integers. For example, +- The values of the matrix will represent numbers of carrots available to the rabbit in each square of the garden. If the garden does not have an exact center, the rabbit should start in the square closest to the center with the highest carrot count. On a given turn, the rabbit will eat the carrots available on the square that it is on, and then move up, down, left, or right, choosing the square that has the most carrots. If there are no carrots left on any of the adjacent squares, the rabbit will go to sleep. You may assume that the rabbit will never have to choose between two squares with the same number of carrots. Write a function which takes a garden matrix and returns the number of carrots the rabbit eats. You may assume the matrix is rectangular with at least 1 row and 1 column, and that it is populated with non-negative integers. For example, - Example: `[[5, 7, 8, 6, 3], [0, 0, 7, 0, 4], [4, 6, 3, 4, 9], [3, 1, 0, 5, 8]]` should return `27`. - Print a matrix in a spiral fashion. - In the Game of life, calculate how to compute the next state of the board. Follow up was to do it if there were memory constraints (board represented by a 1 TB file). diff --git a/algorithms/oop.md b/algorithms/oop.md index 54c32a4c..0df9cc2d 100644 --- a/algorithms/oop.md +++ b/algorithms/oop.md @@ -2,3 +2,7 @@ Object-Oriented Programming == - How would you design a chess game? What classes and objects would you use? What methods would they have? +- How would you design the data structures for a book keeping system for a library? +- Explain how you would design a HTTP server? Give examples of classes, methods, and interfaces. What are the challenges here? +- Discuss algorithms and data structures for a garbage collector? +- How would you implement an HR system to keep track of employee salaries and benefits? diff --git a/algorithms/queue.md b/algorithms/queue.md index 7710f991..31612de9 100644 --- a/algorithms/queue.md +++ b/algorithms/queue.md @@ -2,3 +2,4 @@ Queue == - Implement a Queue class from scratch with an existing bug, the bug is that it cannot take more than 5 elements. +- Implement a Queue using two stacks. You may only use the standard `push()`, `pop()`, and `peek()` operations traditionally available to stacks. You do not need to implement the stack yourself (i.e. an array can be used to simulate a stack). diff --git a/algorithms/stack.md b/algorithms/stack.md index 627ee2c6..063e3a64 100644 --- a/algorithms/stack.md +++ b/algorithms/stack.md @@ -6,3 +6,4 @@ Stack - Write an algorithm to determine if all of the delimiters in an expression are matched and closed. - E.g. `{ac[bb]}`, `[dklf(df(kl))d]{}` and `{[[[]]]}` are matched. But `{3234[fd` and `{df][d}` are not. - [Source](http://blog.gainlo.co/index.php/2016/09/30/uber-interview-question-delimiter-matching/) +- Sort a stack in ascending order using an additional stack. diff --git a/algorithms/string.md b/algorithms/string.md index a6dc8e7d..247aea05 100644 --- a/algorithms/string.md +++ b/algorithms/string.md @@ -4,7 +4,7 @@ String - Output list of strings representing a page of hostings given a list of CSV strings. - Given a list of words, find the word pairs that when concatenated form a palindrome. - Find the most efficient way to identify what character is out of place in a non-palindrome. -- Implement a simple regex parser which, given a string and a pattern, returns a boolean indicating whether the input matches the pattern. By simple, we mean that the regex can only contain special character: `*` (star), `.` (dot), `+` (plus). The star means that there will be zero or more of previous character in that place in the pattern. The dot means any character for that position. The plus means one or more of previous character in that place in the pattern. +- Implement a simple regex parser which, given a string and a pattern, returns a boolean indicating whether the input matches the pattern. By simple, we mean that the regex can only contain the following special characters: `*` (star), `.` (dot), `+` (plus). The star means that there will be zero or more of the previous character in that place in the pattern. The dot means any character for that position. The plus means one or more of previous character in that place in the pattern. - Find all words from a dictionary that are x edit distance away. - Given a string IP and number n, print all CIDR addresses that cover that range. - Write a function called `eval`, which takes a string and returns a boolean. This string is allowed 6 different characters: `0`, `1`, `&`, `|`, `(`, and `)`. `eval` should evaluate the string as a boolean expression, where `0` is `false`, `1` is `true`, `&` is an `and`, and `|` is an `or`. diff --git a/front-end/accessibility.md b/front-end/accessibility.md index dd470f0e..e6f61451 100644 --- a/front-end/accessibility.md +++ b/front-end/accessibility.md @@ -67,7 +67,7 @@ The following is a checklist that contains recommendations for implementing HTML - Accessibility tree = DOM + ARIA. - ARIA attributes - Allow us to modify the accessibility tree before they are exposed to assistive technologies. - - DO NOT modify the element apperance. + - DO NOT modify the element appearance. - DO NOT modify element behaviour. - DO NOT add focusability. - DO NOT add keyboard event handling. diff --git a/front-end/design.md b/front-end/design.md index 38b58ef2..cef9c972 100644 --- a/front-end/design.md +++ b/front-end/design.md @@ -12,7 +12,3 @@ Talk me through a full stack implementation of an autocomplete widget. A user ca - What does the backend API look like? - What perf considerations are there for complete-as-you-type behavior? Are there any edge cases (for example, if the user types fast and the network is slow)? - How would you design the network stack and backend in support of fast performance: how do your client/server communicate? How is your data stored on the backend? How do these approaches scale to lots of data and lots of clients? - -###### References - -- https://performancejs.com/post/hde6d32/The-Best-Frontend-JavaScript-Interview-Questions-%28written-by-a-Frontend-Engineer%29 diff --git a/front-end/html.md b/front-end/html.md index 5b1407ae..97034e16 100644 --- a/front-end/html.md +++ b/front-end/html.md @@ -1,12 +1,16 @@ HTML == -WIP. +HTML (Hypertext Markup Language) is the structure that all websites are built on. Anyone working on websites and webapps should have a basic understanding of HTML at the very least. A helpful analogy for understanding the importance of HTML is the house scenario. When building a new house, the process can be split into a few key areas; structure (HTML), aesthetics (CSS) and furniture (Content). The HTML is your basic page structure, without the structure, you cannot change how it looks using CSS, or what content is on the page. ## Glossary - **Doctype** +## Deprecated Tags + +There are a number of tags from past versions of HTML that have become deprecated over time. This means that while they are no longer considered valid elements, most browsers should still be able to read and render them. + ## Script Loading - `