-## What is this?
+# Front-end Job Interview Questions
-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:
+Unlike typical software engineer job interviews, front-end job interviews have less emphasis on algorithms and have more questions on intricate knowledge and expertise about the domain — HTML, CSS, JavaScript, just to name a few areas.
-- [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
+While there are some existing resources to help front end developers in preparing for interviews, they aren't as abundant as materials for a software engineer interview. Among the existing resources, probably the most helpful question bank would be [Front-end Job Interview Questions](https://github.com/h5bp/Front-end-Developer-Interview-Questions). Unfortunately, I couldn't find many complete and satisfactory answers for these questions online, hence here is my attempt at answering them. Being an open source repository, the project can live on with the support of the community as the state of web evolves.
-This handbook is pretty new and help from you in contributing content would be very much appreciated!
+## Table of Contents
-## Why do I want this?
+1. [HTML Questions](#html-questions)
+1. [CSS Questions](#css-questions)
+1. [JS Questions](#js-questions)
-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.
+## HTML Questions
-## Who is this for?
+Answers to [Front-end Job Interview Questions - HTML Questions](https://github.com/h5bp/Front-end-Developer-Interview-Questions#html-questions). Pull requests for suggestions and corrections are welcome!
-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.
+### What does a `doctype` do?
-## How is this repository different?
+`doctype` is an abbreviation for document type. It is a declaration used in HTML5 to distinguish between a standards-compliant parsing mode and a quirks parsing mode. Hence its presence tells the browser to parse and render the webpage in standards mode.
-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.
+Moral of the story - just add `` at the start of your page.
-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. 😎
+###### References
-## Contents
+* https://stackoverflow.com/questions/7695044/what-does-doctype-html-do
+* https://www.w3.org/QA/Tips/Doctype
-- **[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.
+### What's the difference between full standards mode, almost standards mode and quirks mode?
+
+* **Quirks mode** - Layout emulates non-standard behavior in Netscape Navigator 4 and Internet Explorer 5. This is essential in order to support websites that were built before the widespread adoption of web standards. The list of quirks can be found [here](https://developer.mozilla.org/en-US/docs/Mozilla/Mozilla_quirks_mode_behavior).
+* **Full standards mode** - The layout behavior is the one described by the HTML and CSS specifications.
+* **Almost standards mode** - There are only a very small number of quirks implemented. Differences can be found [here](https://developer.mozilla.org/en-US/docs/Gecko's_Almost_Standards_Mode).
+
+###### References
+
+* https://developer.mozilla.org/en-US/docs/Quirks_Mode_and_Standards_Mode
+
+### What's the difference between HTML and XHTML?
+
+XHTML belongs to the family of XML markups languages and is different from HTML. Some of differences are as follows:
+
+* XHTML documents have to be well-formed, unlike HTML, which is more forgiving.
+* XHTML is case-sensitive for element and attribute names, while HTML is not.
+* Raw `<` and `&` characters are not allowed except inside of `CDATA` Sections (``). JavaScript typically contains characters which can not exist in XHTML outside of CDATA Sections, such as the `<` operator. Hence it is tricky to use inline `styles` or `script` tags in XHTML and should be avoided.
+* A fatal parse error in XML (such as an incorrect tag structure) causes document processing to be aborted.
+
+Full list of differences can be found on [Wikipedia](https://en.wikipedia.org/wiki/XHTML#Relationship_to_HTML).
+
+###### References
+
+* https://developer.mozilla.org/en-US/docs/Archive/Web/Properly_Using_CSS_and_JavaScript_in_XHTML_Documents_
+* https://en.wikipedia.org/wiki/XHTML
+
+### Are there any problems with serving pages as `application/xhtml+xml`?
+
+Basically the problems lie in the differences between parsing HTML and XML as mentioned above.
+
+* XHTML, or rather, XML syntax is less forgiving and if your page isn't fully XML-compliant, there will be parsing errors and users get unreadable content.
+* Serving your pages as `application/xhtml+xml` will cause Internet Explorer 8 to show a download dialog box for an unknown format instead of displaying your page, as the first version of Internet Explorer with support for XHTML is Internet Explorer 9.
+
+###### References
+
+* https://developer.mozilla.org/en-US/docs/Quirks_Mode_and_Standards_Mode#XHTML
+
+### How do you serve a page with content in multiple languages?
+
+The question is a little vague, I will assume that it is asking about the most common case, which is how to serve a page with content available in multiple languages, but the content within the page should be displayed only in one consistent language.
+
+When an HTTP request is made to a server, the requesting user agent usually sends information about language preferences, such as in the `Accept-Language` header. The server can then use this information to return a version of the document in the appropriate language if such an alternative is available. The returned HTML document should also declare the `lang` attribute in the `` tag, such as `...`.
+
+In the back end, the HTML markup will contain `i18n` placeholders and content for the specific language stored in YML or JSON formats. The server then dynamically generates the HTML page with content in that particular language, usually with the help of a back end framework.
+
+###### References
+
+* https://www.w3.org/International/getting-started/language
+
+### What kind of things must you be wary of when designing or developing for multilingual sites?
+
+* Use `lang` attribute in your HTML.
+* Directing users to their native language - Allow a user to change his country/language easily without hassle.
+* Text in images is not a scalable approach - Placing text in an image is still a popular way to get good-looking, non-system fonts to display on any computer. However to translate image text, each string of text will need to have it's a separate image created for each language. Anything more than a handful of replacements like this can quickly get out of control.
+* Restrictive words / sentence length - Some content can be longer when written in another language. Be wary of layout or overflow issues in the design. It's best to avoid designing where the amount of text would make or break a design. Character counts come into play with things like headlines, labels, and buttons. They are less of an issue with free flowing text such as body text or comments.
+* Be mindful of how colors are perceived - Colors are perceived differently across languages and cultures. The design should use color appropriately.
+* Formatting dates and currencies - Calendar dates are sometimes presented in different ways. Eg. "May 31, 2012" in the U.S. vs. "31 May 2012" in parts of Europe.
+* Do not concatenate translated strings - Do not do anything like `"The date today is " + date`. It will break in languages with different word order. Using template parameters instead.
+* Language reading direction - In English, we read from left-to-right, top-to-bottom, in traditional Japanese, text is read up-to-down, right-to-left.
+
+###### References
+
+* https://www.quora.com/What-kind-of-things-one-should-be-wary-of-when-designing-or-developing-for-multilingual-sites
+
+### What are `data-` attributes good for?
+
+Before JavaScript frameworks became popular, front end developers used `data-` attributes to store extra data within the DOM itself, without other hacks such as non-standard attributes, extra properties on the DOM. It is intended to store custom data private to the page or application, for which there are no more appropriate attributes or elements.
+
+These days, using `data-` attributes is not encouraged. One reason is that users can modify the data attribute easily by using inspect element in the browser. The data model is better stored within JavaScript itself and stay updated with the DOM via data binding possibly through a library or a framework.
+
+###### References
+
+* http://html5doctor.com/html5-custom-data-attributes/
+* https://www.w3.org/TR/html5/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes
+
+### Consider HTML5 as an open web platform. What are the building blocks of HTML5?
+
+* Semantics - Allowing you to describe more precisely what your content is.
+* Connectivity - Allowing you to communicate with the server in new and innovative ways.
+* Offline and storage - Allowing webpages to store data on the client-side locally and operate offline more efficiently.
+* Multimedia - Making video and audio first-class citizens in the Open Web.
+* 2D/3D graphics and effects - Allowing a much more diverse range of presentation options.
+* Performance and integration - Providing greater speed optimization and better usage of computer hardware.
+* Device access - Allowing for the usage of various input and output devices.
+* Styling - Letting authors write more sophisticated themes.
+
+###### References
+
+* https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5
+
+### Describe the difference between a `cookie`, `sessionStorage` and `localStorage`.
+
+All the above mentioned technologies are key-value storage mechanisms on the client side. They are only able to store values as strings.
+
+| | `cookie` | `localStorage` | `sessionStorage` |
+| -------------------------------------- | -------------------------------------------------------- | -------------- | ---------------- |
+| Initiator | Client or server. Server can use `Set-Cookie` header | Client | Client |
+| Expiry | Manually set | Forever | On tab close |
+| Persistent across browser sessions | Depends on whether expiration is set | Yes | No |
+| Have domain associated | Yes | No | No |
+| Sent to server with every HTTP request | Cookies are automatically being sent via `Cookie` header | No | No |
+| Capacity (per domain) | 4kb | 5MB | 5MB |
+| Accessibility | Any window | Any window | Same tab |
+
+###### References
+
+* https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies
+* http://tutorial.techaltum.com/local-and-session-storage.html
+
+### Describe the difference between `
+
+
+```
+
+```js
+// File loaded from https://example.com?callback=printData
+printData({ name: 'Yang Shun' });
+```
+
+The client has to have the `printData` function in its global scope and the function will be executed by the client when the response from the cross-origin domain is received.
+
+JSONP can be unsafe and has some security implications. As JSONP is really JavaScript, it can do everything else JavaScript can do, so you need to trust the provider of the JSONP data.
+
+These days, [CORS](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) is the recommended approach and JSONP is seen as a hack.
+
+###### References
+
+* https://stackoverflow.com/a/2067584/1751946
+
+### 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 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 be aware of a potential XSS in the above approach as the contents are not escaped for you, unlike in templating libraries.
+
+### Explain "hoisting".
+
+Hoisting is a term used to explain the behavior of variable declarations in your code. Variables declared or initialized with the `var` keyword will have their declaration "hoisted" up to the top of the current scope. However, only the declaration is hoisted, the assignment (if there is one), will stay where it is. Let's explain with a few examples.
+
+```js
+// var declarations are hoisted.
+console.log(foo); // undefined
+var foo = 1;
+console.log(foo); // 1
+
+// let/const declarations are NOT hoisted.
+console.log(bar); // ReferenceError: bar is not defined
+let bar = 2;
+console.log(bar); // 2
+```
+
+Function declarations have the body hoisted while the function expressions (written in the form of variable declarations) only has the variable declaration hoisted.
+
+```js
+// Function Declaration
+console.log(foo); // [Function: foo]
+foo(); // 'FOOOOO'
+function foo() {
+ console.log('FOOOOO');
+}
+console.log(foo); // [Function: foo]
+
+// Function Expression
+console.log(bar); // undefined
+bar(); // Uncaught TypeError: bar is not a function
+var bar = function() {
+ console.log('BARRRR');
+};
+console.log(bar); // [Function: bar]
+```
+
+### Describe event bubbling.
+
+When an event triggers on a DOM element, it will attempt to handle the event if there is a listener attached, then the event is bubbled up to its parent and the same thing happens. This bubbling occurs up the element's ancestors all the way to the `document`. Event bubbling is the mechanism behind event delegation.
+
+### What's the difference between an "attribute" and a "property"?
+
+Attributes are defined on the HTML markup but properties are defined on the DOM. To illustrate the difference, imagine we have this text field in our HTML: ``.
+
+```js
+const input = document.querySelector('input');
+console.log(input.getAttribute('value')); // Hello
+console.log(input.value); // Hello
+```
+
+But after you change the value of the text field by adding "World!" to it, this becomes:
+
+```js
+console.log(input.getAttribute('value')); // Hello
+console.log(input.value); // Hello World!
+```
+
+###### References
+
+* https://stackoverflow.com/questions/6003819/properties-and-attributes-in-html
+
+### Why is extending built-in JavaScript objects not a good idea?
+
+Extending a built-in/native JavaScript object means adding properties/functions to its `prototype`. While this may seem like a good idea at first, it is dangerous in practice. Imagine your code uses a few libraries that both extend the `Array.prototype` by adding the same `contains` method, the implementations will overwrite each other and your code will break if the behavior of these two methods are not the same.
+
+The only time you may want to extend a native object is when you want to create a polyfill, essentially providing your own implementation for a method that is part of the JavaScript specification but might not exist in the user's browser due to it being an older browser.
+
+###### References
+
+* http://lucybain.com/blog/2014/js-extending-built-in-objects/
+
+### Difference between document load event and document DOMContentLoaded event?
+
+The `DOMContentLoaded` event is fired when the initial HTML document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading.
+
+`window`'s `load` event is only fired after the DOM and all dependent resources and assets have loaded.
+
+###### References
+
+* https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded
+* https://developer.mozilla.org/en-US/docs/Web/Events/load
+
+### What is the difference between `==` and `===`?
+
+`==` is the abstract equality operator while `===` is the strict equality operator. The `==` operator will compare for equality after doing any necessary type conversions. The `===` operator will not do type conversion, so if two values are not the same type `===` will simply return `false`. When using `==`, funky things can happen, such as:
+
+```js
+1 == '1'; // true
+1 == [1]; // true
+1 == true; // true
+0 == ''; // true
+0 == '0'; // true
+0 == false; // true
+```
+
+My advice is never to use the `==` operator, except for convenience when comparing against `null` or `undefined`, where `a == null` will return `true` if `a` is `null` or `undefined`.
+
+```js
+var a = null;
+console.log(a == null); // true
+console.log(a == undefined); // true
+```
+
+###### References
+
+* https://stackoverflow.com/questions/359494/which-equals-operator-vs-should-be-used-in-javascript-comparisons
+
+### Explain the same-origin policy with regards to JavaScript.
+
+The same-origin policy prevents JavaScript from making requests across domain boundaries. An origin is defined as a combination of URI scheme, hostname, and port number. This policy prevents a malicious script on one page from obtaining access to sensitive data on another web page through that page's Document Object Model.
+
+###### References
+
+* https://en.wikipedia.org/wiki/Same-origin_policy
+
+### Make this work:
+
+```js
+duplicate([1, 2, 3, 4, 5]); // [1,2,3,4,5,1,2,3,4,5]
+```
+
+```js
+function duplicate(arr) {
+ return arr.concat(arr);
+}
+
+duplicate([1, 2, 3, 4, 5]); // [1,2,3,4,5,1,2,3,4,5]
+```
+
+### Why is it called a Ternary expression, what does the word "Ternary" indicate?
+
+"Ternary" indicates three, and a ternary expression accepts three operands, the test condition, the "then" expression and the "else" expression. Ternary expressions are not specific to JavaScript and I'm not sure why it is even in this list.
+
+###### References
+
+* https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Conditional_Operator
+
+### What is `"use strict";`? What are the advantages and disadvantages to using it?
+
+'use strict' is a statement used to enable strict mode to entire scripts or individual functions. Strict mode is a way to opt in to a restricted variant of JavaScript.
+
+Advantages:
+
+* Makes it impossible to accidentally create global variables.
+* Makes assignments which would otherwise silently fail to throw an exception.
+* Makes attempts to delete undeletable properties throw (where before the attempt would simply have no effect).
+* Requires that function parameter names be unique.
+* `this` is undefined in the global context.
+* It catches some common coding bloopers, throwing exceptions.
+* It disables features that are confusing or poorly thought out.
+
+Disadvantages:
+
+* Many missing features that some developers might be used to.
+* No more access to `function.caller` and `function.arguments`.
+* Concatenation of scripts written in different strict modes might cause issues.
+
+Overall, I think the benefits outweigh the disadvantages, and I never had to rely on the features that strict mode blocks. I would recommend using strict mode.
+
+###### References
+
+* http://2ality.com/2011/10/strict-mode-hatred.html
+* http://lucybain.com/blog/2014/js-use-strict/
+
+### Create a for loop that iterates up to `100` while outputting **"fizz"** at multiples of `3`, **"buzz"** at multiples of `5` and **"fizzbuzz"** at multiples of `3` and `5`.
+
+Check out this version of FizzBuzz by [Paul Irish](https://gist.github.com/jaysonrowe/1592432#gistcomment-790724).
+
+```js
+for (let i = 1; i <= 100; i++) {
+ let f = i % 3 == 0,
+ b = i % 5 == 0;
+ console.log(f ? (b ? 'FizzBuzz' : 'Fizz') : b ? 'Buzz' : i);
+}
+```
+
+I would not advise you to write the above during interviews though. Just stick with the long but clear approach. For more wacky versions of FizzBuzz, check out the reference link below.
+
+###### References
+
+* https://gist.github.com/jaysonrowe/1592432
+
+### Why is it, in general, a good idea to leave the global scope of a website as-is and never touch it?
+
+Every script has access to the global scope, and if everyone is using the global namespace to define their own variables, there will bound to be collisions. Use the module pattern (IIFEs) to encapsulate your variables within a local namespace.
+
+### Why would you use something like the `load` event? Does this event have disadvantages? Do you know any alternatives, and why would you use those?
+
+The `load` event fires at the end of the document loading process. At this point, all of the objects in the document are in the DOM, and all the images, scripts, links and sub-frames have finished loading.
+
+The DOM event `DOMContentLoaded` will fire after the DOM for the page has been constructed, but do not wait for other resources to finish loading. This is preferred in certain cases when you do not need the full page to be loaded before initializing.
+
+TODO.
+
+###### References
+
+* https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onload
+
+### Explain what a single page app is and how to make one SEO-friendly.
+
+The below is taken from the awesome [Grab Front End Guide](https://github.com/grab/front-end-guide), which coincidentally, is written by me!
+
+Web developers these days refer to the products they build as web apps, rather than websites. While there is no strict difference between the two terms, web apps tend to be highly interactive and dynamic, allowing the user to perform actions and receive a response for their action. Traditionally, the browser receives HTML from the server and renders it. When the user navigates to another URL, a full-page refresh is required and the server sends fresh new HTML for the new page. This is called server-side rendering.
+
+However in modern SPAs, client-side rendering is used instead. The browser loads the initial page from the server, along with the scripts (frameworks, libraries, app code) and stylesheets required for the whole app. When the user navigates to other pages, a page refresh is not triggered. The URL of the page is updated via the [HTML5 History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API). New data required for the new page, usually in JSON format, is retrieved by the browser via [AJAX](https://developer.mozilla.org/en-US/docs/AJAX/Getting_Started) requests to the server. The SPA then dynamically updates the page with the data via JavaScript, which it has already downloaded in the initial page load. This model is similar to how native mobile apps work.
+
+The benefits:
+
+* The app feels more responsive and users do not see the flash between page navigations due to full-page refreshes.
+* Fewer HTTP requests are made to the server, as the same assets do not have to be downloaded again for each page load.
+* Clear separation of the concerns between the client and the server; you can easily build new clients for different platforms (e.g. mobile, chatbots, smart watches) without having to modify the server code. You can also modify the technology stack on the client and server independently, as long as the API contract is not broken.
+
+The downsides:
+
+* Heavier initial page load due to loading of framework, app code, and assets required for multiple pages.
+* There's an additional step to be done on your server which is to configure it to route all requests to a single entry point and allow client-side routing to take over from there.
+* SPAs are reliant on JavaScript to render content, but not all search engines execute JavaScript during crawling, and they may see empty content on your page. This inadvertently hurts the Search Engine Optimization (SEO) of your app. However, most of the time, when you are building apps, SEO is not the most important factor, as not all the content needs to be indexable by search engines. To overcome this, you can either server-side render your app or use services such as [Prerender](https://prerender.io/) to "render your javascript in a browser, save the static HTML, and return that to the crawlers".
+
+###### References
+
+* https://github.com/grab/front-end-guide#single-page-apps-spas
+* http://stackoverflow.com/questions/21862054/single-page-app-advantages-and-disadvantages
+* http://blog.isquaredsoftware.com/presentations/2016-10-revolution-of-web-dev/
+* https://medium.freecodecamp.com/heres-why-client-side-rendering-won-46a349fadb52
+
+### What is the extent of your experience with Promises and/or their polyfills?
+
+Possess working knowledge of it. A promise is an object that may produce a single value some time in the future: either a resolved value, or a reason that it's not resolved (e.g., a network error occurred). A promise may be in one of 3 possible states: fulfilled, rejected, or pending. Promise users can attach callbacks to handle the fulfilled value or the reason for rejection.
+
+Some common polyfills are `$.deferred`, Q and Bluebird but not all of them comply to the specification. ES2015 supports Promises out of the box and polyfills are typically not needed these days.
+
+###### References
+
+* https://medium.com/javascript-scene/master-the-javascript-interview-what-is-a-promise-27fc71e77261
+
+### What are the pros and cons of using Promises instead of callbacks?
+
+**Pros**
+
+* Avoid callback hell which can be unreadable.
+* Makes it easy to write sequential asynchronous code that is readable with `.then()`.
+* Makes it easy to write parallel asynchronous code with `Promise.all()`.
+
+**Cons**
+
+* Slightly more complex code (debatable).
+* In older browsers where ES2015 is not supported, you need to load a polyfill in order to use it.
+
+### What are some of the advantages/disadvantages of writing JavaScript code in a language that compiles to JavaScript?
+
+Some examples of languages that compile to JavaScript include CoffeeScript, Elm, ClojureScript, PureScript and TypeScript.
+
+Advantages:
+
+* Fixes some of the longstanding problems in JavaScript and discourages JavaScript anti-patterns.
+* Enables you to write shorter code, by providing some syntactic sugar on top of JavaScript, which I think ES5 lacks, but ES2015 is awesome.
+* Static types are awesome (in the case of TypeScript) for large projects that need to be maintained over time.
+
+Disadvantages:
+
+* Require a build/compile process as browsers only run JavaScript and your code will need to be compiled into JavaScript before being served to browsers.
+* Debugging can be a pain if your source maps do not map nicely to your pre-compiled source.
+* Most developers are not familiar with these languages and will need to learn it. There's a ramp up cost involved for your team if you use it for your projects.
+* Smaller community (depends on the language), which means resources, tutorials, libraries and tooling would be harder to find.
+* IDE/editor support might be lacking.
+* These languages will always be behind the latest JavaScript standard.
+* Developers should be cognizant of what their code is being compiled to — because that is what would actually be running, and that is what matters in the end.
+
+Practically, ES2015 has vastly improved JavaScript and made it much nicer to write. I don't really see the need for CoffeeScript these days.
+
+###### References
+
+* https://softwareengineering.stackexchange.com/questions/72569/what-are-the-pros-and-cons-of-coffeescript
+
+### What tools and techniques do you use for debugging JavaScript code?
+
+* React and Redux
+ * [React Devtools](https://github.com/facebook/react-devtools)
+ * [Redux Devtools](https://github.com/gaearon/redux-devtools)
+* JavaScript
+ * [Chrome Devtools](https://hackernoon.com/twelve-fancy-chrome-devtools-tips-dc1e39d10d9d)
+ * `debugger` statement
+ * Good old `console.log` debugging
+
+###### References
+
+* https://hackernoon.com/twelve-fancy-chrome-devtools-tips-dc1e39d10d9d
+* https://raygun.com/blog/javascript-debugging/
+
+### What language constructions do you use for iterating over object properties and array items?
+
+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:
+
+* `for` loops - `for (var i = 0; i < arr.length; i++)`. The common pitfall here is that `var` is in the function scope and not the block scope and most of the time you would want block scoped iterator variable. ES2015 introduces `let` which has block scope and it is recommended to use that instead. So this becomes: `for (let i = 0; i < arr.length; i++)`.
+* `forEach` - `arr.forEach(function (el, index) { ... })`. This construct can be more convenient at times because you do not have to use the `index` if all you need is the array elements. There are also the `every` and `some` methods which will allow you to terminate the iteration early.
+
+Most of the time, I would prefer the `.forEach` method, but it really depends on what you are trying to do. `for` loops allow more flexibility, such as prematurely terminate the loop using `break` or incrementing the iterator more than once per loop.
+
+### Explain the difference between mutable and immutable objects.
+
+* What is an example of an immutable object in JavaScript?
+* What are the pros and cons of immutability?
+* How can you achieve immutability in your own code?
+
+TODO
+
+### Explain the difference between synchronous and asynchronous functions.
+
+Synchronous functions are blocking while asynchronous functions are not. In synchronous functions, statements complete before the next statement is run. In this case the program is evaluated exactly in order of the statements and execution of the program is paused if one of the statements take a very long time.
+
+Asynchronous functions usually accept a callback as a parameter and execution continues on the next line immediately after the asynchronous function is invoked. The callback is only invoked when the asynchronous operation is complete and the call stack is empty. Heavy duty operations such as loading data from a web server or querying a database should be done asynchronously so that the main thread can continue executing other operations instead of blocking until that long operation to complete (in the case of browsers, the UI will freeze).
+
+### What is event loop? What is the difference between call stack and task queue?
+
+The event loop is a single-threaded loop that monitors the call stack and checks if there is any work to be done in the task queue. If the call stack is empty and there are callback functions in the task queue, a function is dequeued and pushed onto the call stack to be executed.
+
+If you haven't already checked out Philip Robert's [talk on the Event Loop](https://2014.jsconf.eu/speakers/philip-roberts-what-the-heck-is-the-event-loop-anyway.html), you should. It is one of the most viewed videos on JavaScript.
+
+###### References
+
+* https://2014.jsconf.eu/speakers/philip-roberts-what-the-heck-is-the-event-loop-anyway.html
+* http://theproactiveprogrammer.com/javascript/the-javascript-event-loop-a-stack-and-a-queue/
+
+### Explain the differences on the usage of `foo` between `function foo() {}` and `var foo = function() {}`
+
+The former is a function declaration while the latter is a function expression. The key difference is that function declarations have its body hoisted but the bodies of function expressions are not (they have the same hoisting behaviour as variables). For more explanation on hoisting, refer to the question above on hoisting. If you try to invoke a function expression before it is defined, you will get an `Uncaught TypeError: XXX is not a function` error.
+
+**Function Declaration**
+
+```js
+foo(); // 'FOOOOO'
+function foo() {
+ console.log('FOOOOO');
+}
+```
+
+**Function Expression**
+
+```js
+foo(); // Uncaught TypeError: foo is not a function
+var foo = function() {
+ console.log('FOOOOO');
+};
+```
+
+###### References
+
+* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function
+
+### Other Answers
+
+* http://flowerszhong.github.io/2013/11/20/javascript-questions.html
## Related
@@ -64,9 +1324,4 @@ If you are interested in how data structures are implemented, check out [Lago](h
## Contributing
-There are no formal contributing guidelines at the moment as things are still in flux and we might find a better approach to structure content as we go along. You are welcome to contribute whatever you think will be helpful to fellow engineers. If you would like to contribute content for different domains, feel free to create an issue or submit a pull request and we can discuss further.
-
-## Maintainers
-
-- [Yangshun Tay](https://github.com/yangshun)
-- [Louie Tan](https://github.com/louietyj)
+Feel free to make pull requests to correct any mistakes in the answers or suggest new questions.
diff --git a/algorithms/README.md b/algorithms/README.md
deleted file mode 100644
index abc4ca9e1..000000000
--- a/algorithms/README.md
+++ /dev/null
@@ -1,578 +0,0 @@
-Algorithm Questions
-==
-
-This section dives deep into practical tips for specific topics of algorithms and data structures which appear frequently in coding questions. Many algorithm questions involve techniques that can be applied to questions of similar nature. The more techniques you have in your arsenal, the higher the chances of passing the interview. They may lead you to discover corner cases you might have missed out or even lead you towards the optimal approach!
-
-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)
-- [Dynamic Programming and Memoization](dynamic-programming.md)
-- [Geometry](geometry.md)
-- [Graph](graph.md)
-- [Hash Table](hash-table.md)
-- [Heap](heap.md)
-- [Interval](interval.md)
-- [Linked List](linked-list.md)
-- [Math](math.md)
-- [Matrix](matrix.md)
-- [Object-Oriented Programming](oop.md)
-- [Permutation](permutation.md)
-- [Queue](queue.md)
-- [Sorting and Searching](sorting-searching.md)
-- [Stack](stack.md)
-- [String](string.md)
-- [Tree](tree.md)
-
-## 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?
-
-Check for off-by-one errors.
-
-In languages where there are no automatic type coercion, check that concatenation of values are of the same type: `int`/`str`/`list`.
-
-After finishing your code, use a few example inputs to test your solution.
-
-Is the algorithm meant to be run multiple times, for example in a web server? If yes, the input is likely to be preprocess-able to improve the efficiency in each call.
-
-Use a mix of functional and imperative programming paradigms:
-
-- Write pure functions as much as possible.
-- Pure functions are easier to reason about and can help to reduce bugs in your implementation.
-- Avoid mutating the parameters passed into your function especially if they are passed by reference unless you are sure of what you are doing.
-- However, functional programming is usually expensive in terms of space complexity because of non-mutation and the repeated allocation of new objects. On the other hand, imperative code is faster because you operate on existing objects. Hence you will need to achieve a balance between accuracy vs efficiency, by using the right amount of functional and imperative code where appropriate.
-- Avoid relying on and mutating global variables. Global variables introduce state.
-- If you have to rely on global variables, make sure that you do not mutate it by accident.
-
-Generally, to improve the speed of a program, we can either choose a more appropriate data structure/algorithm or use more memory. It's a classic space/time tradeoff.
-
-Data structures are your weapons. Choosing the right weapon for the right battle is the key to victory. Be very familiar about the strengths of each data structure and the time complexities for its various operations.
-
-Data structures can be augmented to achieve efficient time complexities across different operations. For example, a hash map can be used together with a doubly-linked list to achieve O(1) time complexity for both the `get` and `put` operation in an [LRU cache](https://leetcode.com/problems/lru-cache/).
-
-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 may not cover all cases.
-
-## Sequence
-
-#### Notes
-
-Arrays and strings are considered sequences (a string is a sequence of characters). There are tips relevant for dealing with both arrays and strings which will be covered here.
-
-Are there duplicate values in the sequence, would it affect the answer?
-
-Check for sequence out of bounds.
-
-Be mindful about slicing or concatenating sequences in your code. Typically, slicing and concatenating sequences require O(n) time. Use start and end indices to demarcate a subarray/substring where possible.
-
-Sometimes you can traverse the sequence from the right rather than from the left.
-
-Master the [sliding window technique](https://discuss.leetcode.com/topic/30941/here-is-a-10-line-template-that-can-solve-most-substring-problems) that applies to many substring/subarray problems.
-
-When you are given two sequences to process, it is common to have one index per sequence to traverse/compare the both of them. For example, we use the same approach to merge two sorted arrays.
-
-#### Corner Cases
-
-- Empty sequence.
-- Sequence with 1 or 2 elements.
-- Sequence with repeated elements.
-
-## Array
-
-#### Notes
-
-Is the array sorted or partially sorted? If it is, some form of binary search should be possible. This also usually means that the interviewer is looking for a solution that is faster than O(n).
-
-Can you sort the array? Sometimes sorting the array first may significantly simplify the problem. Make sure that the order of array elements do not need to be preserved before attempting a sort.
-
-For questions where summation or multiplication of a subarray is involved, pre-computation using hashing or a prefix/suffix sum/product might be useful.
-
-If you are given a sequence and the interviewer asks for O(1) space, it might be possible to use the array itself as a hash table. For example, if the array only has values from 1 to N, where N is the length of the array, negate the value at that index (minus one) to indicate presence of that number.
-
-#### Practice Questions
-
-- [Two Sum](https://leetcode.com/problems/two-sum/)
-- [Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/)
-- [Contains Duplicate](https://leetcode.com/problems/contains-duplicate/)
-- [Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self/)
-- [Maximum Subarray](https://leetcode.com/problems/maximum-subarray/)
-- [Maximum Product Subarray](https://leetcode.com/problems/maximum-product-subarray/)
-- [Find Minimum in Rotated Sorted Array](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/)
-- [Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array/)
-- [3Sum](https://leetcode.com/problems/3sum/)
-- [Container With Most Water](https://leetcode.com/problems/container-with-most-water/)
-
-## Binary
-
-#### Study Links
-
-- [Bits, Bytes, Building With Binary](https://medium.com/basecs/bits-bytes-building-with-binary-13cb4289aafa)
-
-#### Notes
-
-Questions involving binary representations and bitwise operations are asked sometimes and you must be absolutely familiar with how to convert a number from decimal form into binary form (and vice versa) in your chosen programming language.
-
-Some helpful utility snippets:
-
-- Test kth bit is set: `num & (1 << k) != 0`.
-- Set kth bit: `num |= (1 << k)`.
-- Turn off kth bit: `num &= ~(1 << k)`.
-- Toggle the kth bit: `num ^= (1 << k)`.
-- To check if a number is a power of 2, `num & num - 1 == 0`.
-
-#### Corner Cases
-
-- Check for overflow/underflow.
-- Negative numbers.
-
-#### Practice Questions
-
-- [Sum of Two Integers](https://leetcode.com/problems/sum-of-two-integers/)
-- [Number of 1 Bits](https://leetcode.com/problems/number-of-1-bits/)
-- [Counting Bits](https://leetcode.com/problems/counting-bits/)
-- [Missing Number](https://leetcode.com/problems/missing-number/)
-- [Reverse Bits](https://leetcode.com/problems/reverse-bits/)
-
-## Dynamic Programming
-
-#### Study Links
-
-- [Demystifying Dynamic Programming](https://medium.freecodecamp.org/demystifying-dynamic-programming-3efafb8d4296)
-
-#### Notes
-
-Dynamic Programming (DP) is usually used to solve optimization problems. The only way to get better at DP is to practice. It takes some amount of practice to be able to recognize that a problem can be solved by DP.
-
-Sometimes you do not need to store the whole DP table in memory, the last two values or the last two rows of the matrix will suffice.
-
-#### Practice Questions
-
-- 0/1 Knapsack
-- [Climbing Stairs](https://leetcode.com/problems/climbing-stairs/)
-- [Coin Change](https://leetcode.com/problems/coin-change/)
-- [Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence/)
-- [Longest Common Subsequence]()
-- [Word Break Problem](https://leetcode.com/problems/word-break/)
-- [Combination Sum](https://leetcode.com/problems/combination-sum-iv/)
-- [House Robber](https://leetcode.com/problems/house-robber/) and [House Robber II](https://leetcode.com/problems/house-robber-ii/)
-- [Decode Ways](https://leetcode.com/problems/decode-ways/)
-- [Unique Paths](https://leetcode.com/problems/unique-paths/)
-- [Jump Game](https://leetcode.com/problems/jump-game/)
-
-## Geometry
-
-#### Notes
-
-When comparing euclidean distance between two pairs of points, using dx2 + dy2 is sufficient. It is unnecessary to square root the value.
-
-To find out if two circles overlap, check that the distance between the two centers of the circles is less than the sum of their radii.
-
-## Graph
-
-#### Study Links
-
-- [From Theory To Practice: Representing Graphs](https://medium.com/basecs/from-theory-to-practice-representing-graphs-cfd782c5be38)
-- [Deep Dive Through A Graph: DFS Traversal](https://medium.com/basecs/deep-dive-through-a-graph-dfs-traversal-8177df5d0f13)
-- [Going Broad In A Graph: BFS Traversal](https://medium.com/basecs/going-broad-in-a-graph-bfs-traversal-959bd1a09255)
-
-#### Notes
-
-Be familiar with the various graph representations, graph search algorithms and their time and space complexities.
-
-You can be given a list of edges and tasked to build your own graph from the edges to perform a traversal on. The common graph representations are:
- - Adjacency matrix.
- - Adjacency list.
- - Hashmap of hashmaps.
-
-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:
-
-- **Common** - Breadth-first Search, Depth-first Search
-- **Uncommon** - Topological Sort, Dijkstra's algorithm
-- **Rare** - Bellman-Ford algorithm, Floyd-Warshall algorithm, Prim's algorithm, Kruskal's algorithm
-
-In coding interviews, graphs are commonly represented as 2-D matrices where cells are the nodes and each cell can traverse to its adjacent cells (up/down/left/right). Hence it is important that you be familiar with traversing a 2-D matrix. When recursively traversing the matrix, always ensure that your next position is within the boundary of the matrix. More tips for doing depth-first searches on a matrix can be found [here](https://discuss.leetcode.com/topic/66065/python-dfs-bests-85-tips-for-all-dfs-in-matrix-question/). A simple template for doing depth-first searches on a matrix goes like this:
-
-```py
-def traverse(matrix):
- rows, cols = len(matrix), len(matrix[0])
- visited = set()
- directions = ((0, 1), (0, -1), (1, 0), (-1, 0))
- def dfs(i, j):
- if (i, j) in visited:
- return
- visited.add((i, j))
- # Traverse neighbors
- for direction in directions:
- next_i, next_j = i + direction[0], j + direction[1]
- if 0 <= next_i < rows and 0 <= next_j < cols: # Check boundary
- # Add any other checking here ^
- dfs(next_i, next_j)
-
- for i in range(rows):
- for j in range(cols):
- dfs(i, j)
-```
-
-#### Corner Cases
-
-- Empty graph.
-- Graph with one or two nodes.
-- Disjoint graphs.
-- Graph with cycles.
-
-#### Practice Questions
-
-- [Clone Graph](https://leetcode.com/problems/clone-graph/)
-- [Course Schedule](https://leetcode.com/problems/course-schedule/)
-- [Pacific Atlantic Water Flow](https://leetcode.com/problems/pacific-atlantic-water-flow/)
-- [Number of Islands](https://leetcode.com/problems/number-of-islands/)
-- [Longest Consecutive Sequence](https://leetcode.com/problems/longest-consecutive-sequence/)
-- [Alien Dictionary (Leetcode Premium)](https://leetcode.com/problems/alien-dictionary/)
-- [Graph Valid Tree (Leetcode Premium)](https://leetcode.com/problems/graph-valid-tree/)
-- [Number of Connected Components in an Undirected Graph (Leetcode Premium)](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/)
-
-## Interval
-
-#### Notes
-
-Interval questions are questions where you are given an array of two-element arrays (an interval) and the two values represent a start and an end value. Interval questions are considered part of the array family but they involve some common techniques hence they are extracted out to this special section of their own.
-
-An example interval array: `[[1, 2], [4, 7]]`.
-
-Interval questions can be tricky to those who have not tried them before because of the sheer number of cases to consider when they overlap.
-
-Do clarify with the interviewer whether `[1, 2]` and `[2, 3]` are considered overlapping intervals as it affects how you will write your equality checks.
-
-A common routine for interval questions is to sort the array of intervals by each interval's starting value.
-
-Be familiar with writing code to check if two intervals overlap and merging two overlapping intervals:
-
-```py
-def is_overlap(a, b):
- return a[0] < b[1] and b[0] < a[1]
-
-def merge_overlapping_intervals(a, b):
- return [min(a[0], b[0]), max(a[1], b[1])]
-```
-
-#### Corner Cases
-
-- Single interval.
-- Non-overlapping intervals.
-- An interval totally consumed within another interval.
-- Duplicate intervals.
-
-#### Practice Questions
-
-- [Insert Interval](https://leetcode.com/problems/insert-interval/)
-- [Merge Intervals](https://leetcode.com/problems/merge-intervals/)
-- [Non-overlapping Intervals](https://leetcode.com/problems/non-overlapping-intervals/)
-- [Meeting Rooms (Leetcode Premium)](https://leetcode.com/problems/meeting-rooms/) and [Meeting Rooms II (Leetcode Premium)](https://leetcode.com/problems/meeting-rooms-ii/)
-
-## Linked List
-
-#### Notes
-
-Like arrays, linked lists are used to represent sequential data. The benefit of linked lists is that insertion and deletion from anywhere in the list is O(1) whereas in arrays the following elements will have to be shifted.
-
-Adding a dummy node at the head and/or tail might help to handle many edge cases where operations have to be performed at the head or the tail. The presence of dummy nodes essentially ensures that operations will never have be done on the head or the tail, thereby removing a lot of headache in writing conditional checks to dealing with null pointers. Be sure to remember to remove them at the end of the operation.
-
-Sometimes linked lists problem can be solved without additional storage. Try to borrow ideas from reverse a linked list problem.
-
-For deletion in linked lists, you can either modify the node values or change the node pointers. You might need to keep a reference to the previous element.
-
-For partitioning linked lists, create two separate linked lists and join them back together.
-
-Linked lists problems share similarity with array problems, think about how you would do it for an array and try to apply it to a linked list.
-
-Two pointer approaches are also common for linked lists. For example:
- - Getting the kth from last node - Have two pointers, where one is k nodes ahead of the other. When the node ahead reaches the end, the other node is k nodes behind.
- - Detecting cycles - Have two pointers, where one pointer increments twice as much as the other, if the two pointers meet, means that there is a cycle.
- - Getting the middle node - Have two pointers, where one pointer increments twice as much as the other. When the faster node reaches the end of the list, the slower node will be at the middle.
-
-Be familiar with the following routines because many linked list questions make use of one or more of these routines in the solution:
- - Counting the number of nodes in the linked list.
- - Reversing a linked list in-place.
- - Finding the middle node of the linked list using fast/slow pointers.
- - Merging two lists together.
-
-#### Corner Cases
-
-- Single node.
-- Two nodes.
-- Linked list has cycle. Clarify with the interviewer whether there can be a cycle in the list. Usually the answer is no.
-
-#### Practice Questions
-
-- [Reverse a Linked List](https://leetcode.com/problems/reverse-linked-list/)
-- [Detect Cycle in a Linked List](https://leetcode.com/problems/linked-list-cycle/)
-- [Merge Two Sorted Lists](https://leetcode.com/problems/merge-two-sorted-lists/)
-- [Merge K Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists/)
-- [Remove Nth Node From End Of List](https://leetcode.com/problems/remove-nth-node-from-end-of-list/)
-- [Reorder List](https://leetcode.com/problems/reorder-list/)
-
-## Math
-
-#### Notes
-
-If code involves division or modulo, remember to check for division or modulo by 0 case.
-
-When a question involves "a multiple of a number", perhaps modulo might be useful.
-
-Check for and handle overflow/underflow if you are using a typed language like Java and C++. At the very least, mention that overflow/underflow is possible and ask whether you need to handle it.
-
-Consider negative numbers and floating point numbers. This may sound obvious, but under interview pressure, many obvious cases go unnoticed.
-
-If the question asks to implement an operator such as power, squareroot or division and want it to be faster than O(n), binary search is usually the approach to go.
-
-#### Some common formulas:
-
-- Sum of 1 to N = (n+1) * n/2
-- Sum of GP = 20 + 21 + 22 + 23 + ... 2n = 2n+1 - 1
-- Permutations of N = N! / (N-K)!
-- Combinations of N = N! / (K! * (N-K)!)
-
-#### Practice Questions
-
-- [Pow(x, n)](https://leetcode.com/problems/powx-n/)
-- [Sqrt(x)](https://leetcode.com/problems/sqrtx/)
-- [Integer to English Words](https://leetcode.com/problems/integer-to-english-words/)
-
-## Matrix
-
-#### Notes
-
-A matrix is a 2-dimensional array. Questions involving matrices are usually related to dynamic programming or graph traversal.
-
-For questions involving traversal or dynamic programming, you almost always want to make a copy of the matrix with the same dimensions that is initialized to empty values to store the visited state or dynamic programming table. Be familiar with such a routine:
-
-```py
-rows, cols = len(matrix), len(matrix[0])
-copy = [[0 for _ in range(cols)] for _ in range(rows)]
-```
-
-Many grid-based games can be modeled as a matrix, such as Tic-Tac-Toe, Sudoku, Crossword, Connect 4, Battleship, etc. It is not uncommon to be asked to verify the winning condition of the game. For games like Tic-Tac-Toe, Connect 4 and Crosswords, where verification has to be done vertically and horizontally, one trick is to write code to verify the matrix for the horizontal cells, transpose the matrix and reuse the logic for horizontal verification to verify originally vertical cells (which are now horizontal).
-
-Transposing a matrix in Python is simply:
-
-```py
-transposed_matrix = zip(*matrix)
-```
-
-#### Corner Cases
-
-- Empty matrix. Check that none of the arrays are 0 length.
-- 1 x 1 matrix.
-- Matrix with only one row or column.
-
-#### Practice Questions
-
-- [Set Matrix Zeroes](https://leetcode.com/problems/set-matrix-zeroes/)
-- [Spiral Matrix](https://leetcode.com/problems/spiral-matrix/)
-- [Rotate Image](https://leetcode.com/problems/rotate-image/)
-- [Word Search](https://leetcode.com/problems/word-search/)
-
-## Recursion
-
-#### Notes
-
-Recursion is useful for permutation, because it generates all combinations and tree-based questions. You should know how to generate all permutations of a sequence as well as how to handle duplicates.
-
-Remember to always define a base case so that your recursion will end.
-
-Recursion implicitly uses a stack. Hence all recursive approaches can be rewritten iteratively using a stack. Beware of cases where the recursion level goes too deep and causes a stack overflow (the default limit in Python is 1000). You may get bonus points for pointing this out to the interviewer. Recursion will never be O(1) space complexity because a stack is involved, unless there is [tail-call optimization](https://stackoverflow.com/questions/310974/what-is-tail-call-optimization) (TCO). Find out if your chosen language supports TCO.
-
-#### Practice Questions
-
-- [Subsets](https://leetcode.com/problems/subsets/) and [Subsets II](https://leetcode.com/problems/subsets-ii/)
-- [Strobogrammatic Number II (Leetcode Premium)](https://leetcode.com/problems/strobogrammatic-number-ii/)
-
-## String
-
-#### Notes
-
-Please read the above tips on sequence. They apply to strings too.
-
-Ask about input character set and case sensitivity. Usually the characters are limited to lowercase Latin characters, for example a to z.
-
-When you need to compare strings where the order isn’t important (like anagram), you may consider using a HashMap as a counter. If your language has a built-in Counter class like Python, ask to use that instead.
-
-If you need to keep a counter of characters, a common mistake is to say that the space complexity required for the counter is O(n). The space required for a counter is O(1) not O(n). This is because the upper bound is the range of characters, which is usually a fixed constant of 26. The input set is just lowercase Latin characters.
-
-Common data structures for looking up strings efficiently are
-
-- [Trie / Prefix Tree](https://en.wikipedia.org/wiki/Trie)
-- [Suffix Tree](https://en.wikipedia.org/wiki/Suffix_tree)
-
-Common string algorithms are
-
-- [Rabin Karp](https://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm) for efficient searching of substring using a rolling hash.
-- [KMP](https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm) for efficient searching of substring.
-
-#### Corner Cases
-
-- Strings with only one distinct character.
-
-#### Non-repeating Characters
-
-- Use a 26-bit bitmask to indicate which lower case latin characters are inside the string.
-
-```py
-mask = 0
-for c in set(word):
- mask |= (1 << (ord(c) - ord('a')))
-```
-
-To determine if two strings have common characters, perform & on the two bitmasks. If the result is non-zero, `mask_a & mask_b > 0`, then the two strings have common characters.
-
-### Anagram
-
-An anagram is word switch or word play. It is the result of re-arranging the letters of a word or phrase to produce a new word or phrase, while using all the original letters only once. In interviews, usually we are only bothered with words without spaces in them.
-
-To determine if two strings are anagrams, there are a few plausible approaches:
-
-- Sorting both strings should produce the same resulting string. This takes O(nlgn) time and O(lgn) space.
-- If we map each character to a prime number and we multiply each mapped number together, anagrams should have the same multiple (prime factor decomposition). This takes O(n) time and O(1) space.
-- Frequency counting of characters will help to determine if two strings are anagrams. This also takes O(n) time and O(1) space.
-
-### Palindrome
-
-A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward, such as *madam* or *racecar*.
-
-Here are ways to determine if a string is a palindrome:
-
-- Reverse the string and it should be equal to itself.
-- Have two pointers at the start and end of the string. Move the pointers inward till they meet. At any point in time, the characters at both pointers should match.
-
-The order of characters within the string matters, so HashMaps are usually not helpful.
-
-When a question is about counting the number of palindromes, a common trick is to have two pointers that move outward, away from the middle. Note that palindromes can be even or odd length. For each middle pivot position, you need to check it twice: Once that includes the character and once without the character.
-
-- For substrings, you can terminate early once there is no match.
-- For subsequences, use dynamic programming as there are overlapping subproblems. Check out [this question](https://leetcode.com/problems/longest-palindromic-subsequence/).
-
-#### Practice Questions
-
-- [Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters/)
-- [Longest Repeating Character Replacement](https://leetcode.com/problems/longest-repeating-character-replacement/)
-- [Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring/description/)
-- [Valid Anagram](https://leetcode.com/problems/valid-anagram)
-- [Group Anagrams](https://leetcode.com/problems/group-anagrams/)
-- [Valid Parentheses](https://leetcode.com/problems/valid-parentheses)
-- [Valid Palindrome](https://leetcode.com/problems/valid-palindrome/)
-- [Longest Palindromic Substring](https://leetcode.com/problems/longest-palindromic-substring/)
-- [Palindromic Substrings](https://leetcode.com/problems/palindromic-substrings/)
-- [Encode and Decode Strings (Leetcode Premium)](https://leetcode.com/problems/encode-and-decode-strings/)
-
-## Tree
-
-#### Study Links
-
-- [Leaf It Up To Binary Trees](https://medium.com/basecs/leaf-it-up-to-binary-trees-11001aaf746d)
-
-#### Notes
-
-A tree is an undirected and connected acyclic graph.
-
-Recursion is a common approach for trees. When you notice that the subtree problem can be used to solve the entire problem, try using recursion.
-
-When using recursion, always remember to check for the base case, usually where the node is `null`.
-
-When you are asked to traverse a tree by level, use depth first search.
-
-Sometimes it is possible that your recursive function needs to return two values.
-
-If the question involves summation of nodes along the way, be sure to check whether nodes can be negative.
-
-You should be very familiar with writing pre-order, in-order, and post-order traversal recursively. As an extension, challenge yourself by writing them iteratively. Sometimes interviewers ask candidates for the iterative approach, especially if the candidate finishes writing the recursive approach too quickly.
-
-
-#### Corner Cases
-
-- Empty tree.
-- Single node.
-- Two nodes.
-- Very skewed tree (like a linked list).
-
-### Binary Tree
-
-In-order traversal of a binary tree is insufficient to uniquely serialize a tree. Pre-order or post-order traversal is also required.
-
-### Binary Search Tree (BST)
-
-In-order traversal of a BST will give you all elements in order.
-
-Be very familiar with the properties of a BST and validating that a binary tree is a BST. This comes up more often than expected.
-
-When a question involves a BST, the interviewer is usually looking for a solution which runs faster than O(n).
-
-#### Practice Questions
-
-- [Maximum Depth of Binary Tree](https://leetcode.com/problems/maximum-depth-of-binary-tree/)
-- [Same Tree](https://leetcode.com/problems/same-tree/)
-- [Invert/Flip Binary Tree](https://leetcode.com/problems/invert-binary-tree/)
-- [Binary Tree Maximum Path Sum](https://leetcode.com/problems/binary-tree-maximum-path-sum/)
-- [Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal/)
-- [Serialize and Deserialize Binary Tree](https://leetcode.com/problems/serialize-and-deserialize-binary-tree/)
-- [Subtree of Another Tree](https://leetcode.com/problems/subtree-of-another-tree/)
-- [Construct Binary Tree from Preorder and Inorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/)
-- [Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree/)
-- [Kth Smallest Element in a BST](https://leetcode.com/problems/kth-smallest-element-in-a-bst/)
-- [Lowest Common Ancestor of BST](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/)
-
-## Trie
-
-#### Study Links
-
-- [Trying to Understand Tries](https://medium.com/basecs/trying-to-understand-tries-3ec6bede0014)
-- [Implement Trie (Prefix Tree)](https://leetcode.com/articles/implement-trie-prefix-tree/)
-
-#### Notes
-
-Tries are special trees (prefix trees) that make searching and storing strings more efficient. Tries have many practical applications, such as conducting searches and providing autocomplete. It is helpful to know these common applications so that you can easily identify when a problem can be efficiently solved using a trie.
-
-Sometimes preprocessing a dictionary of words (given in a list) into a trie, will improve the efficiency of searching for a word of length k, among n words. Searching becomes O(k) instead of O(n).
-
-Be familiar with implementing, from scratch, a `Trie` class and its `add`, `remove` and `search` methods.
-
-#### Practice Questions
-
-- [Implement Trie (Prefix Tree)](https://leetcode.com/problems/implement-trie-prefix-tree)
-- [Add and Search Word](https://leetcode.com/problems/add-and-search-word-data-structure-design)
-- [Word Search II](https://leetcode.com/problems/word-search-ii/)
-
-## Heap
-
-#### Study Links
-
-- [Learning to Love Heaps](https://medium.com/basecs/learning-to-love-heaps-cef2b273a238)
-
-#### Notes
-
-If you see a top or lowest *k* being mentioned in the question, it is usually a signal that a heap can be used to solve the problem, such as in [Top K Frequent Elements](https://leetcode.com/problems/top-k-frequent-elements/).
-
-If you require the top *k* elements use a Min Heap of size *k*. Iterate through each element, pushing it into the heap. Whenever the heap size exceeds *k*, remove the minimum element, that will guarantee that you have the *k* largest elements.
-
-#### Practice Questions
-
-- [Merge K Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists/)
-- [Top K Frequent Elements](https://leetcode.com/problems/top-k-frequent-elements/)
-- [Find Median from Data Stream](https://leetcode.com/problems/find-median-from-data-stream/)
-
-###### References
-
-- http://blog.triplebyte.com/how-to-pass-a-programming-interview
-- https://quip.com/q41AA3OmoZbC
-- http://www.geeksforgeeks.org/must-do-coding-questions-for-companies-like-amazon-microsoft-adobe/
-- https://medium.com/basecs
diff --git a/algorithms/array.md b/algorithms/array.md
deleted file mode 100644
index 0de9fedc1..000000000
--- a/algorithms/array.md
+++ /dev/null
@@ -1,60 +0,0 @@
-Arrays
-==
-
-- 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.
-- 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 using the said array; include a base layer (all stars)
- - E.g. `[5, 4, 0, 3, 4, 1]`
-
-```
-*
-** *
-** **
-** **
-** ***
-******
-```
-
-- Given an array and an index, find the product of the elements of the array except the element at that index.
-- Given a set of rectangles represented by a height and an interval along the y-axis, determine the size of its union.
-- Given 2 separate arrays, write a method to find the values that exist in both arrays and return them.
-- Given an array of integers find whether there is a sub-sequence that sums to 0 and return it.
- - E.g. `[1, 2, -3, 1]` => `[1, 2, -3]` or `[2, -3, 1]`.
-- Given an input array and another array that describes a new index for each element, mutate the input array so that each element ends up in their new index. Discuss the runtime of the algorithm and how you can be sure there would not be any infinite loops.
-- Given an array of non-negative numbers, find continuous subarray with sum to S.
- - [Source](http://blog.gainlo.co/index.php/2016/06/01/subarray-with-given-sum/).
-- Given an array of numbers list out all triplets that sum to 0. Do so with a running time of less than O(n^3).
- - [Source](http://blog.gainlo.co/index.php/2016/07/19/3sum/).
-- Given an array of numbers list out all quadruplets that sum to 0. Do so with a running time of less than O(n^4).
-- Given an array of integers, move all the zeroes to the end while preserving the order of the other elements. You have to do it in-place and are not allowed to use any extra storage.
-- Given an array of integers, find the subarray with the largest sum. Can you do it in linear time.
- - Maximum subarray sum problem.
-- You have an array with the heights of an island (at point 1, point 2 etc) and you want to know how much water would remain on this island (without flowing away).
- - Trapping rain water question.
-- Given an array containing only digits `0-9`, add one to the number and return the array.
- - E.g. Given `[1, 4, 2, 1]` which represents `1421`, return `[1, 4, 2, 2]` which represents `1422`.
-- Find the second maximum value in an array.
-- Given an array, find the longest arithmetic progression.
-- Rotate an array by an offset of k.
-- Remove duplicates in an unsorted array where the duplicates are at a distance of k or less from each other.
-- Given an unsorted list of integers, return true if the list contains any duplicates within k indices of each element. Do it faster than O(n^2).
-- Given an unsorted list of integers, return true if the list contains any fuzzy duplicates within k indices of each element. A fuzzy duplicate is another integer within d of the original integer. Do it faster than O(n^2).
- - E.g. If d = 4, then 6 is a fuzzy duplicate of 3 but 8 is not.
-- Say you have an unordered list of numbers ranging from 1 to n, and one of the numbers is removed, how do you find that number? What if two numbers are removed?
-- Given an array of string, find the duplicated elements.
- - [Source](http://blog.gainlo.co/index.php/2016/05/10/duplicate-elements-of-an-array/).
-- Given an array of integers, find a maximum sum of non-adjacent elements.
- - E.g. `[1, 0, 3, 9, 2]` should return `10 (1 + 9)`.
- - [Source](http://blog.gainlo.co/index.php/2016/12/02/uber-interview-question-maximum-sum-non-adjacent-elements/)
-- Given an array of integers, modify the array by moving all the zeros to the end (right side). The order of other elements doesn't matter.
- - E.g. `[1, 2, 0, 3, 0, 1, 2]`, the program can output `[1, 2, 3, 1, 2, 0, 0]`.
- - [Source](http://blog.gainlo.co/index.php/2016/11/18/uber-interview-question-move-zeroes/).
-- 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
deleted file mode 100644
index 76aa41539..000000000
--- a/algorithms/bit-manipulation.md
+++ /dev/null
@@ -1,7 +0,0 @@
-Bit Manipulation
-==
-
-- How do you verify if an interger is a power of 2?
-- 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.
diff --git a/algorithms/dynamic-programming.md b/algorithms/dynamic-programming.md
deleted file mode 100644
index 978fa611d..000000000
--- a/algorithms/dynamic-programming.md
+++ /dev/null
@@ -1,26 +0,0 @@
-Dynamic Programming
-==
-
-- Given a flight itinerary consisting of starting city, destination city, and ticket price (2D list) - find the optimal price flight path to get from start to destination. (A variation of Dynamic Programming Shortest Path)
-- 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 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
- The above array would represent an example booking period as follows -
- // Dec 1 - 5
- // Dec 5 - 6
- // 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.
-
- Similarly,
- // [3, 6, 4] => 7
- // [4, 10, 3, 1, 5] => 15
- ~~~
-- Given a list of denominations (e.g., `[1, 2, 5]` means you have coins worth $1, $2, and $5) and a target number `k`, find all possible combinations, if any, of coins in the given denominations that add up to `k`. You can use coins of the same denomination more than once.
diff --git a/algorithms/geometry.md b/algorithms/geometry.md
deleted file mode 100644
index 062f861bf..000000000
--- a/algorithms/geometry.md
+++ /dev/null
@@ -1,7 +0,0 @@
-Geometry
-==
-
-- You have a plane with lots of rectangles on it, find out how many of them intersect.
-- Which data structure would you use to query the k-nearest points of a set on a 2D plane?
-- Given many points, find k points that are closest to the origin.
-- How would you triangulate a polygon?
diff --git a/algorithms/graph.md b/algorithms/graph.md
deleted file mode 100644
index 119000baf..000000000
--- a/algorithms/graph.md
+++ /dev/null
@@ -1,10 +0,0 @@
-Graph
-==
-
-- Given a list of sorted words from an alien dictionary, find the order of the alphabet.
- - Alien Dictionary Topological Sort question.
-- Find if a given string matches any path in a labeled graph. A path may contain cycles.
-- Given a bipartite graph, separate the vertices into two sets.
-- You are a thief trying to sneak across a rectangular 100 x 100m field. There are alarms placed on the fields and they each have a circular sensing radius which will trigger if anyone steps into it. Each alarm has its own radius. Determine if you can get from one end of the field to the other end.
-- Given a graph and two nodes, determine if there exists a path between them.
-- Determine if a cycle exists in the graph.
diff --git a/algorithms/hash-table.md b/algorithms/hash-table.md
deleted file mode 100644
index c8655047c..000000000
--- a/algorithms/hash-table.md
+++ /dev/null
@@ -1,7 +0,0 @@
-Hash Table
-==
-
-- Describe an implementation of a least-used cache, and big-O notation of it.
-- A question involving an API's integration with hash map where the buckets of hash map are made up of linked lists.
-- Implement data structure `Map` storing pairs of integers (key, value) and define following member functions in O(1) runtime: `void insert(key, value)`, `void delete(key)`, `int get(key)`, `int getRandomKey()`.
- - [Source](http://blog.gainlo.co/index.php/2016/08/14/uber-interview-question-map-implementation/).
diff --git a/algorithms/heap.md b/algorithms/heap.md
deleted file mode 100644
index 1e68064fe..000000000
--- a/algorithms/heap.md
+++ /dev/null
@@ -1,5 +0,0 @@
-Heap
-==
-
-- Merge `K` sorted lists together into a single list.
-- Given a stream of integers, write an efficient function that returns the median value of the integers.
diff --git a/algorithms/interval.md b/algorithms/interval.md
deleted file mode 100644
index 5dd3e373e..000000000
--- a/algorithms/interval.md
+++ /dev/null
@@ -1,28 +0,0 @@
-Interval
-==
-
-- Given a list of schedules, provide a list of times that are available for a meeting.
- ```
- [
- [[4,5], [6,10], [12,14]],
- [[4,5], [5,9], [13,16]],
- [[11,14]]
- ]
-
- Example Output:
- [[0,4], [11,12], [16,23]]
- ```
-- You have a number of meetings (with their start and end times). You need to schedule them using the minimum number of rooms. Return the list of meetings in every room.
-- Interval ranges:
- - Given 2 interval ranges, create a function to tell me if these ranges intersect. Both start and end are inclusive: `[start, end]`
- - E.g. `[1, 4]` and `[5, 6]` => `false`
- - E.g. `[1, 4]` and `[3, 6]` => `true`
- - Given 2 interval ranges that intersect, now create a function to merge the 2 ranges into a single continuous range.
- - E.g. `[1, 4]` and `[3, 6]` => `[1, 6]`
- - Now create a function that takes a group of unsorted, unorganized intervals, merge any intervals that intersect and sort them. The result should be a group of sorted, non-intersecting intervals.
- - Now create a function to merge a new interval into a group of sorted, non-intersecting intervals. After the merge, all intervals should remain
- non-intersecting.
-- Given a list of meeting times, check if any of them overlap. The follow-up question is to return the minimum number of rooms required to accommodate all the meetings.
- - [Source](http://blog.gainlo.co/index.php/2016/07/12/meeting-room-scheduling-problem/)
-- If you have a list of intervals, how would you merge them?
- - E.g. `[1, 3], [8, 11], [2, 6]` => `[1, 6], [8-11]`
diff --git a/algorithms/linked-list.md b/algorithms/linked-list.md
deleted file mode 100644
index 8dd1dbdd6..000000000
--- a/algorithms/linked-list.md
+++ /dev/null
@@ -1,12 +0,0 @@
-Linked List
-==
-
-- Given a linked list, in addition to the next pointer, each node has a child pointer that can point to a separate list. With the head node, flatten the list to a single-level linked list.
- - [Source](http://blog.gainlo.co/index.php/2016/06/12/flatten-a-linked-list/)
-- Reverse a singly linked list. Implement it recursively and iteratively.
-- Convert a binary tree to a doubly circular linked list.
-- Implement an LRU cache with O(1) runtime for all its operations.
-- Check distance between values in 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?
diff --git a/algorithms/math.md b/algorithms/math.md
deleted file mode 100644
index fdff1ce5f..000000000
--- a/algorithms/math.md
+++ /dev/null
@@ -1,20 +0,0 @@
-Math
-==
-
-- Create a square root function.
-- Given a string such as "123" or "67", write a function to output the number represented by the string without using casting.
-- Make a program that can print out the text form of numbers from 1 - 1000 (ex. 20 is "twenty", 105 is "one hundred and five").
-- Write a function that parses Roman numerals.
- - E.g. `XIV` returns `14`.
-- Write in words for a given digit.
- - E.g. `123` returns `one hundred and twenty three`.
-- Given a number `N`, find the largest number just smaller than `N` that can be formed using the same digits as `N`.
-- Compute the square root of `N` without using any existing functions.
-- Given numbers represented as binary strings, and return the string containing their sum.
- - E.g. `add('10010', '101')` returns `'10111'`.
-- Take in an integer and return its english word-format.
- - E.g. 1 -> "one", -10,203 -> "negative ten thousand two hundred and three".
-- Write a function that returns values randomly, according to their weight. Suppose we have 3 elements with their weights: A (1), B (1) and C (2). The function should return A with probability 25%, B with 25% and C with 50% based on the weights.
- - [Source](http://blog.gainlo.co/index.php/2016/11/11/uber-interview-question-weighted-random-numbers/)
-- Given a number, how can you get the next greater number with the same set of digits?
- - [Source](http://blog.gainlo.co/index.php/2017/01/20/arrange-given-numbers-to-form-the-biggest-number-possible/)
diff --git a/algorithms/matrix.md b/algorithms/matrix.md
deleted file mode 100644
index a0977e9e1..000000000
--- a/algorithms/matrix.md
+++ /dev/null
@@ -1,18 +0,0 @@
-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 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).
-- Grid Illumination: Given an NxN grid with an array of lamp coordinates. Each lamp provides illumination to every square on their x axis, every square on their y axis, and every square that lies in their diagonal (think of a Queen in chess). Given an array of query coordinates, determine whether that point is illuminated or not. The catch is when checking a query all lamps adjacent to, or on, that query get turned off. The ranges for the variables/arrays were about: 10^3 < N < 10^9, 10^3 < lamps < 10^9, 10^3 < queries < 10^9.
-- You are given a matrix of integers. Modify the matrix such that if a row or column contains a 0, make the values in the entire row or column 0.
-- Given an N x N matrix filled randomly with different colors (no limit on what the colors are), find the total number of groups of each color - a group consists of adjacent cells of the same color touching each other.
-- You have a 4 x 4 board with characters. You need to write a function that finds if a certain word exists in the board. You can only jump to neighboring characters (including diagonally adjacent).
-- Count the number of islands in a binary matrix of 0's and 1's.
-- Check a 6 x 7 Connect 4 board for a winning condition.
-- Given a fully-filled Sudoku board, check whether fulfills the Sudoku condition.
-- Implement a function that checks if a player has won tic-tac-toe.
-- Given an N x N matrix of 1's and 0's, figure out if all of the 1's are connected.
diff --git a/algorithms/oop.md b/algorithms/oop.md
deleted file mode 100644
index 0df9cc2da..000000000
--- a/algorithms/oop.md
+++ /dev/null
@@ -1,8 +0,0 @@
-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/permutation.md b/algorithms/permutation.md
deleted file mode 100644
index 00116bf6b..000000000
--- a/algorithms/permutation.md
+++ /dev/null
@@ -1,12 +0,0 @@
-Permutation
-==
-
-- You are given a 7 digit phone number, and you should find all possible letter combinations based on the digit-to-letter mapping on numeric pad and return only the ones that have valid match against a given dictionary of words.
-- Give all possible letter combinations from a phone number.
-- Generate all subsets of a string.
-- Print all possible `N` pairs of balanced parentheses.
- - E.g. when `N` is `2`, the function should print `(())` and `()()`.
- - E.g. when `N` is `3`, we should get `((()))`, `(()())`, `(())()`, `()(())`, `()()()`.
- - [Source](http://blog.gainlo.co/index.php/2016/12/23/uber-interview-questions-permutations-parentheses/)
-- Given a list of arrays, return a list of arrays, where each array is a combination of one element in each given array.
- - E.g. If the input is `[[1, 2, 3], [4], [5, 6]]`, the output should be `[[1, 4, 5], [1, 4, 6], [2, 4, 5], [2, 4, 6], [3, 4, 5], [3, 4, 6]]`.
diff --git a/algorithms/queue.md b/algorithms/queue.md
deleted file mode 100644
index 31612de9b..000000000
--- a/algorithms/queue.md
+++ /dev/null
@@ -1,5 +0,0 @@
-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/sorting-searching.md b/algorithms/sorting-searching.md
deleted file mode 100644
index 4b36ba959..000000000
--- a/algorithms/sorting-searching.md
+++ /dev/null
@@ -1,16 +0,0 @@
-Sorting and Searching
-==
-
-- Sorting search results on a page given a certain set of criteria.
-- Sort a list of numbers in which each number is at a distance `K` from its actual position.
-- Given an array of integers, sort the array so that all odd indexes are greater than the even indexes.
-- Given users with locations in a list and a logged-in user with locations, find their travel buddies (people who shared more than half of your locations).
-- Search for an element in a sorted and rotated array.
- - [Source](http://blog.gainlo.co/index.php/2017/01/12/rotated-array-binary-search/)
-- Sort a list where each element is no more than k positions away from its sorted position.
-- Search for an item in a sorted, but rotated, array.
-- Merge two sorted lists together.
-- Give 3 distinct algorithms to find the K largest values in a list of N items.
-- Find the minimum element in a sorted rotated array in faster than O(n) time.
-- Write a function that takes a number as input and outputs the biggest number with the same set of digits.
- - [Source](http://blog.gainlo.co/index.php/2017/01/20/arrange-given-numbers-to-form-the-biggest-number-possible/)
diff --git a/algorithms/stack.md b/algorithms/stack.md
deleted file mode 100644
index 063e3a645..000000000
--- a/algorithms/stack.md
+++ /dev/null
@@ -1,9 +0,0 @@
-Stack
-==
-
-- Implementation of an interpreter for a small language that does multiplication/addition/etc.
-- Design a `MinStack` data structure that supports a `min()` operation that returns the minimum value in the stack in O(1) time.
-- 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
deleted file mode 100644
index 247aea051..000000000
--- a/algorithms/string.md
+++ /dev/null
@@ -1,58 +0,0 @@
-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 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`.
- - E.g `"(0 | (1 | 0)) & (1 & ((1 | 0) & 0))"`
-- Given a pattern string like `"abba"` and an input string like `"redbluebluered"`, return `true` if and only if there's a one to one mapping of letters in the pattern to substrings of the input.
- - E.g. `"abba"` and `"redbluebluered"` should return `true`.
- - E.g. `"aaaa"` and `"asdasdasdasd"` should return `true`.
- - E.g. `"aabb"` and `"xyzabcxzyabc"` should return `false`.
-- If you received a file in chunks, calculate when you have the full file. Quite an open-ended question. Can assume chunks come with start and end, or size, etc.
-- Given a list of names (strings) and the width of a line, design an algorithm to display them using the minimum number of lines.
-- Design a spell-checking algorithm.
-- Count and say problem.
-- Longest substring with `K` unique characters.
- - [Source](http://blog.gainlo.co/index.php/2016/04/12/find-the-longest-substring-with-k-unique-characters/)
-- Given a set of random strings, write a function that returns a set that groups all the anagrams together.
- - [Source](http://blog.gainlo.co/index.php/2016/05/06/group-anagrams/)
-- Given a string, find the longest substring without repeating characters. For example, for string `'abccdefgh'`, the longest substring is `'cdefgh'`.
- - [Source](http://blog.gainlo.co/index.php/2016/10/07/facebook-interview-longest-substring-without-repeating-characters/)
-- Given a string, return the string with duplicate characters removed.
-- Write a function that receives a regular expression (allowed chars = from `'a'` to `'z'`, `'*'`, `'.'`) and a string containing lower case english alphabet characters and return `true` or `false` whether the string matches the regex.
- - E.g. `'ab*a'`, `'abbbbba'` => `true`.
- - E.g. `'ab*b.'`, `'aba'` => `true`.
- - E.g. `'abc*'`, `'acccc'` => `false`.
-- Given a rectangular grid with letters, search if some word is in the grid.
-- Given two strings representing integer numbers (`'123'` , `'30'`) return a string representing the sum of the two numbers: `'153'`.
-- A professor wants to see if two students have cheated when writing a paper. Design a function `hasCheated(String s1, String s2, int N)` that evaluates to `true` if two strings have a common substring of length `N`.
- - Follow up: Assume you don't have the possibility of using `String.contains()` and `String.substring()`. How would you implement this?
-- Print all permutations of a given string.
-- Parse a string containing numbers and `'+'`, `'-'` and parentheses. Evaluate the expression. `-2+(3-5)` should return `-4`.
-- Output a substring with at most `K` unique characters.
- - E.g. `'aabc'` and `k` = 2 => `'aab'`.
-- Ensure that there are a minimum of `N` dashes between any two of the same characters of a string.
- - E.g. `n = 2, string = 'ab-bcdecca'` => `'ab--bcdec--ca'`.
-- Find the longest palindrome in a string.
-- Give the count and the number following in the series.
- - E.g. `1122344`, next: `21221324`, next: `12112211121214`.
- - Count and say problem.
-- Compress a string by grouping consecutive similar questions together:
- - E.g. `'aaabbbcc' => `'a3b3c2'`.
-- You have a string consisting of open and closed parentheses, but parentheses may be imbalanced. Make the parentheses balanced and return the new string.
-- Given a set of strings, return the smallest subset that contains prefixes for every string.
- - E.g. `['foo', 'foog', 'food', 'asdf']` => `['foo', 'asdf']`.
-- Write a function that would return all the possible words generated when using a phone (pre-smartphone era) numpad to type.
-- Given a dictionary and a word, find the minimum number of deletions needed on the word in order to make it a valid word.
- - [Source](http://blog.gainlo.co/index.php/2016/04/29/minimum-number-of-deletions-of-a-string/)
-- How to check if a string contains an anagram of another string?
- - [Source](http://blog.gainlo.co/index.php/2016/04/08/if-a-string-contains-an-anagram-of-another-string/)
-- Find all k-lettered words from a string.
-- Given a string of open and close parentheses, find the minimum number of edits needed to balance a string of parentheses.
-- Run length encoding - Write a string compress function that returns `'R2G1B1'` given `'RRGB'`.
-- Write a function that finds all the different ways you can split up a word into a concatenation of two other words.
diff --git a/algorithms/topics.md b/algorithms/topics.md
deleted file mode 100644
index 9718e7e78..000000000
--- a/algorithms/topics.md
+++ /dev/null
@@ -1,89 +0,0 @@
-Topics
-==
-
-## Arrays
-
-## Strings
-
-- Prefix trees (Tries)
-- Suffix trees
-- Suffix arrays
-- KMP
-- Rabin-Karp
-- Boyer-Moore
-
-## Sorting
-
-- Bubble sort
-- Insertion sort
-- Merge sort
-- Quick sort
-- Selection sort
-- Bucket sort
-- Radix sort
-- Counting sort
-
-## Linked Lists
-
-## Stacks
-
-## Queues
-
-## Hash tables
-
-- Collision resolution algorithms
-
-## Trees
-
-- BFS
-- DFS (inorder, postorder, preorder)
-- Height
-
-## Binary Search Trees
-
-- Insert node
-- Delete a node
-- Find element in BST
-- Find min, max element in BST
-- Get successor element in tree
-- Check if a binary tree is a BST or not
-
-## Heaps / Priority Queues
-
-- Insert
-- Bubble up
-- Extract max
-- Remove
-- Heapify
-- Heap sort
-
-## Graphs
-
-- Various implementations
- - Adjacency matrix
- - Adjacency list
- - Adjacency map
-- Single-source shortest path
-- Dijkstra
-- Bellman-Ford
-- Topo sort
-- MST
-- Prim algorithm
-- Kruskal's algorithm
-- Union Find Data Structure
-- Count connected components in a graph
-- List strongly connected components in a graph
-- Check for bipartite graph
-
-## Dynamic Programming
-
-- Count Change
-- 0-1 Knapsack
-
-## System Design
-
-- http://www.hiredintech.com/system-design/
-- https://www.quora.com/How-do-I-prepare-to-answer-design-questions-in-a-technical-interview?redirected_qid=1500023
-- http://blog.gainlo.co/index.php/2015/10/22/8-things-you-need-to-know-before-system-design-interviews/
-- https://github.com/donnemartin/system-design-primer
-- https://github.com/jwasham/coding-interview-university/blob/master/extras/cheat%20sheets/system-design.pdf
diff --git a/algorithms/tree.md b/algorithms/tree.md
deleted file mode 100644
index be7720db3..000000000
--- a/algorithms/tree.md
+++ /dev/null
@@ -1,36 +0,0 @@
-Tree
-==
-
-- Find the height of a tree.
-- Find the longest path from the root to leaf in a tree.
-- Find the deepest left leaf of a tree.
-- Print all paths of a binary tree.
- - [Source](http://blog.gainlo.co/index.php/2016/04/15/print-all-paths-of-a-binary-tree/)
-- Second largest element of a BST.
- - [Source](http://blog.gainlo.co/index.php/2016/06/03/second-largest-element-of-a-binary-search-tree/)
-- Given a binary tree and two nodes, how to find the common ancestor of the two nodes?
- - [Source](http://blog.gainlo.co/index.php/2016/07/06/lowest-common-ancestor/)
-- Find the lowest common ancestor of two nodes in a binary search tree.
-- Print the nodes in an n-ary tree level by level, one printed line per level.
-- Given a directory of files and folders (and relevant functions), how would you parse through it to find equivalent files?
-- Write a basic file system and implement the commands ls, pwd, mkdir, create, rm, cd, cat, mv.
-- Compute the intersection of two binary search trees.
-- Given a binary tree, output all the node to leaf paths of it.
-- Given a string of characters without spaces, is there a way to break the string into valid words without leftover characters?
-- Print a binary tree level by level.
-- Determine if a binary tree is "complete" (i.e, if all leaf nodes were either at the maximum depth or max depth-1, and were 'pressed' along the left side of the tree).
-- Find the longest path in a binary tree. The path may start and end at any node.
-- Determine if a binary tree is a BST.
-- Given a binary tree, serialize it into a string. Then deserialize it.
-- Print a binary tree by column.
-- Given a node, find the next element in a BST.
-- Find the shortest subtree that consist of all the deepest nodes. The tree is not binary.
-- Print out the sum of each row in a binary tree.
-- Pretty print a JSON object.
-- Convert a binary tree to a doubly circular linked list.
-- Find the second largest number in a binary tree.
-- Given a tree, find the longest branch.
-- Convert a tree to a linked list.
-- Given two trees, write code to find out if tree A is a subtree of tree B.
-- Deepest node in a tree.
- - [Source](http://blog.gainlo.co/index.php/2016/04/26/deepest-node-in-a-tree/)
diff --git a/design/README.md b/design/README.md
deleted file mode 100644
index 08004f550..000000000
--- a/design/README.md
+++ /dev/null
@@ -1,95 +0,0 @@
-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
-- https://gist.github.com/vasanthk/485d1c25737e8e72759f
-- http://www.puncsky.com/blog/2016/02/14/crack-the-system-design-interview/
-- https://www.palantir.com/2011/10/how-to-rock-a-systems-design-interview/
-- http://blog.gainlo.co/index.php/2017/04/13/system-design-interviews-part-ii-complete-guide-google-interview-preparation/
-
-## Flow
-
-#### A. Understand the problem and scope
-
-- Define the use cases, with interviewer's help.
-- Suggest additional features.
-- Remove items that interviewer deems out of scope.
-- Assume high availability is required, add as a use case.
-
-#### B. Think about constraints
-
-- Ask how many requests per month.
-- Ask how many requests per second (they may volunteer it or make you do the math).
-- Estimate reads vs. writes percentage.
-- Keep 80/20 rule in mind when estimating.
-- How much data written per second.
-- Total storage required over 5 years.
-- How much data reads per second.
-
-#### C. Abstract design
-
-- Layers (service, data, caching).
-- Infrastructure: load balancing, messaging.
-- Rough overview of any key algorithm that drives the service.
-- Consider bottlenecks and determine solutions.
-
-Source: https://github.com/jwasham/coding-interview-university#system-design-scalability-data-handling
-
-## Grading Rubrics
-
-- Problem Solving - How systematic is your approach to solving the problem step-by-step? Break down a problem into its core components.
-- Communication - How well do you explain your idea and communicate it with others?
-- Evaluation - How do you evaluate your system? Are you aware of the trade-offs made? How can you optimize it?
-- Estimation - How fast does your system need to be? How much space does it need? How much load will it experience?
-
-## Specific Topics
-
-- URL Shortener
- - http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener
- - http://blog.gainlo.co/index.php/2016/03/08/system-design-interview-question-create-tinyurl-system/
- - https://www.interviewcake.com/question/python/url-shortener
-- Collaborative Editor
- - http://blog.gainlo.co/index.php/2016/03/22/system-design-interview-question-how-to-design-google-docs/
-- Photo Sharing App
- - http://blog.gainlo.co/index.php/2016/03/01/system-design-interview-question-create-a-photo-sharing-app/
-- Social Network Feed
- - http://blog.gainlo.co/index.php/2016/02/17/system-design-interview-question-how-to-design-twitter-part-1/
- - http://blog.gainlo.co/index.php/2016/02/24/system-design-interview-question-how-to-design-twitter-part-2/
- - http://blog.gainlo.co/index.php/2016/03/29/design-news-feed-system-part-1-system-design-interview-questions/
-- Trending Algorithm
- - http://blog.gainlo.co/index.php/2016/05/03/how-to-design-a-trending-algorithm-for-twitter/
-- Facebook Chat
- - http://blog.gainlo.co/index.php/2016/04/19/design-facebook-chat-function/
-- Key Value Store
- - http://blog.gainlo.co/index.php/2016/06/14/design-a-key-value-store-part-i/
- - http://blog.gainlo.co/index.php/2016/06/21/design-key-value-store-part-ii/
-- Recommendation System
- - http://blog.gainlo.co/index.php/2016/05/24/design-a-recommendation-system/
-- Cache System
- - http://blog.gainlo.co/index.php/2016/05/17/design-a-cache-system/
-- E-commerce Website
- - http://blog.gainlo.co/index.php/2016/08/22/design-ecommerce-website-part/
- - http://blog.gainlo.co/index.php/2016/08/28/design-ecommerce-website-part-ii/
-- Web Crawler
- - http://blog.gainlo.co/index.php/2016/06/29/build-web-crawler/
- - http://www.makeuseof.com/tag/how-do-search-engines-work-makeuseof-explains/
- - https://www.quora.com/How-can-I-build-a-web-crawler-from-scratch/answer/Chris-Heller
-- YouTube
- - http://blog.gainlo.co/index.php/2016/10/22/design-youtube-part/
- - http://blog.gainlo.co/index.php/2016/11/04/design-youtube-part-ii/
-- Hit Counter
- - http://blog.gainlo.co/index.php/2016/09/12/dropbox-interview-design-hit-counter/
-- Facebook Graph Search
-- Design [Lyft Line](https://www.lyft.com/line).
-- Design a promo code system (with same promo code, randomly generated promo code, and promo code with conditions).
-- Model a university.
-- How would you implement Pacman?
-- Sketch out an implementation of Asteroids.
-- Implement a spell checker.
-- Design the rubik cube.
-- Design a high-level interface to be used for card games (e.g. poker, blackjack etc).
diff --git a/design/collaborative-editor.md b/design/collaborative-editor.md
deleted file mode 100644
index 2f9427c14..000000000
--- a/design/collaborative-editor.md
+++ /dev/null
@@ -1,108 +0,0 @@
-Collaborative Document Editor
-==
-
-## Variants
-
-- Design Google docs.
-- Design a collaborative code editor like Coderpad/Codepile.
-- Design a collaborative markdown editor.
-
-## Requirements Gathering
-
-- What is the intended platform?
- - Web
-- What features are required?
- - Creating a document
- - Editing a document
- - Sharing a document
-- Bonus features
- - Document revisions and reverting
- - Searching
- - Commenting
- - Chatting
- - Executing code (in the case of code editor)
-- What is in a document?
- - Text
- - Images
-- Which metrics should we optimize for?
- - Loading time
- - Synchronization
- - Throughput
-
-## Core Components
-
-- Front end
- - WebSockets/long polling for real-time communication between front end and back end.
-- Back end services behind a reverse proxy.
- - Reverse proxy will proxy the requests to the right server.
- - Split into a few services for different purposes.
- - The benefit of this is that each service can use different languages that best suits its purpose.
-- API servers for non-collaborative features and endpoints.
- - Ruby/Rails/Django for the server that deals with CRUD operations on data models where performance is not that crucial.
-- WebSocket servers for handling document edits and publishing updates to listeners.
- - Possibly Node/Golang for WebSocket server which will need high performance as updates are frequent.
-- Task queue to persist document updates to the database.
-- ELB in front of back end servers.
-- MySQL database.
-- S3 and CDN for images.
-
-## Data Modeling
-
-- What kind of database to use?
- - Data is quite structured. Would go with SQL.
-- Design the necessary tables, its columns and its relations.
- - `users`
- - `id`
- - `name`
- - `document`
- - `id`
- - `owner_id`
- - `permissions`
- - `id`
- - `name`
- - `document_permissions`
- - `id`
- - `document_id`
- - `user_id`
-
-## Collaborative Editing - Client
-
-- Upon loading of the page and document, the client should connect to the WebSocket server over the WebSocket protocol `ws://`.
-- Upon connection, perform a time sync with the server, possibly via Network Time Protocol (NTP).
-- The most straightforward way is to send the whole updated document content to the back end, and all users currently viewing the document will receive the updated document. However, there are a few problems with this approach:
- - Race condition. If two users editing the document at the same time, the last one to edit will overwrite the changes by the previous user. One workaround is to lock the document when a user is currently editing it, but that will not make it real-time collaborative.
- - A large payload (the whole document) is being sent to servers and published to users on each change, and the user is likely to already have most of the content. A lot of redundant data being sent.
-- A feasible approach would be to use operational transforms and send just the action deltas to the back end. The back end publishes the action deltas to the listeners. What is considered an action delta?
- - (a) Changing a character/word, (b) inserting a character/word/image, (c) deleting a character/word.
- - With this approach, the payload will contain only small amount of data, such as (a) type of change, (b) character/word, (c) position in document: line/column, (d) timestamp. Why is the timestamp needed? Read on to find out.
-- Updates can also be throttled and batched, to avoid flooding the web server with requests. For example, if a user inserts a
-
-## Back End
-
-The back end is split into a few portions: WebSocket server for receiving and broadcasting document updates, CRUD server for reading and writing non-document-related data, and a task queue for persistence of the document.
-
-## WebSocket Server
-
-- Languages and frameworks that support async requests and non-blocking I/O will be suitable for the collaborative editor server. Node and Golang comes to my mind.
-- However, the WebSocket server is not stateless, so is it not that straightforward to scale horizontally. One approach would be for a Load Balancer to use Redis to maintain a map of the client to the WebSocket server instance IP, such that subsequent requests from the same client will be routed to the same server.
-- Each document corresponds to a room (more of namespace). Users can subscribe to the events happening within a room.
-- When a action delta is being received, blast it out to the listeners within the room and add it to the task queue.
-
-## CRUD Server
-
-- Provides APIs for reading and writing non-document-related data, such as users, permissions.
-
-## Task Queue + Worker Service
-
-- Worker service retrieves messages from the task queue and writes the updated documents to the database in an async fashion.
-- Batch the actions together and perform one larger write that consists of multiple actions. For example, instead of persisting to the database once per addition of a word, combine these additions and write them into the database at once.
-- Publish the save completion event to the WebSocket server to be published to the listeners, informing that the latest version of the document is being saved.
-- Benefit of using a task queue is that as the amount of tasks in the queue goes up, we can scale up the number of worker services to clear the backlog of work faster.
-
-## Document Persistence
-
-TODO
-
-###### References
-
-- http://blog.gainlo.co/index.php/2016/03/22/system-design-interview-question-how-to-design-google-docs/
diff --git a/design/news-feed.md b/design/news-feed.md
deleted file mode 100644
index 8dccbfd29..000000000
--- a/design/news-feed.md
+++ /dev/null
@@ -1,164 +0,0 @@
-News Feed
-==
-
-## Variants
-
-- Design Facebook news feed.
-- Design Twitter news feed.
-- Design Quora feed.
-- Design Instagram feed.
-
-## Requirements Gathering
-
-- What is the intended platform?
- - Mobile (mobile web or native)? Web? Desktop?
-- What features are required?
- - CRUD posts.
- - Commenting on posts.
- - Sharing posts.
- - Trending posts?
- - Tag people?
- - Hashtags?
-- What is in a news feed post?
- - Author.
- - Content.
- - Media.
- - Tags?
- - Hashtags?
- - Comments/Replies.
- - Operations:
- - CRUD
- - Commenting/replying to a post.
-- What is in a news feed?
- - Sequence of posts.
- - Query pattern: query for a user's ranked news feed.
- - Operations:
- - Append - Fetch more posts.
- - Delete - I don't want to see this.
-- Which metrics should we optimize for?
- - User retention.
- - Ads revenue.
- - Fast loading time.
- - Bandwidth.
- - Server costs.
-
-## Core Components
-
-TODO
-
-## Data modeling
-
-- What kind of database to use?
- - Data is quite structured. Would go with SQL.
-- Design the necessary tables, its columns and its relations.
- - `users`
- - `posts`
- - `likes`
- - `follows`
- - `comments`
-
-> There are two basic objects: user and feed. For user object, we can store userID, name, registration date and so on so forth. And for feed object, there are feedId, feedType, content, metadata etc., which should support images and videos as well.
->
-> If we are using a relational database, we also need to model two relations: user-feed relation and friend relation. The former is pretty straightforward. We can create a user-feed table that stores userID and corresponding feedID. For a single user, it can contain multiple entries if he has published many feeds.
->
-> For friend relation, adjacency list is one of the most common approaches. If we see all the users as nodes in a giant graph, edges that connect nodes denote friend relation. We can use a friend table that contains two userIDs in each entry to model the edge (friend relation). By doing this, most operations are quite convenient like fetch all friends of a user, check if two people are friends.
->
-> The system will first get all userIDs of friends from friend table. Then it fetches all feedIDs for each friend from user-feed table. Finally, feed content is fetched based on feedID from feed table. You can see that we need to perform 3 joins, which can affect performance.
->
-> A common optimization is to store feed content together with feedID in user-feed table so that we don't need to join the feed table any more. This approach is called denormalization, which means by adding redundant data, we can optimize the read performance (reducing the number of joins).
->
-> The disadvantages are obvious:
-> - Data redundancy. We are storing redundant data, which occupies storage space (classic time-space trade-off).
-> - Data consistency. Whenever we update a feed, we need to update both feed table and user-feed table. Otherwise, there is data inconsistency. This increases the complexity of the system.
-> - Remember that there's no one approach always better than the other (normalization vs denormalization). It's a matter of whether you want to optimize for read or write.
-
-## Feed Display
-
-- The most straightforward way is to fetch posts from all the people you follow and render them sorted by time.
-- There can be many posts to fetch. How many posts should you fetch?
- - What are the pagination approaches and the pros and cons of each approach?
- - Offset by page size
- - Offset by time
-- What data should the post contain when you initially fetch them?
-- Lazy loading approach for loading associated data: media, comments, people who liked the post.
-- Media
- - If the post contains media such as images and videos, how should they be handled? Should they be loaded on the spot?
- - A better way would be to fetch images only when they are about to enter the viewport.
- - Videos should not autoplay. Only fetch the thumbnail for the video, and only play the video when user clicks play.
- - If the content is being refetched, the media should be cached and not fetched over the wire again. This is especially important on mobile connections where data can be expensive.
-- Comments
- - Should you fetch all the comments for a post? For posts by celebrities, they can contain a few hundred or thousand comments.
- - Maybe fetch the top few comments and display them under the post, and the user is given the choice to "show all comments".
-- How does the user request for new content?
- - Infinite scrolling.
- - User has to tap next page.
-
-## Feed Ranking
-
-- First select features/signals that are relevant and then figure out how to combine them to calculate a final score.
-- How do you show the relevant posts that the user is interested in?
- - Chronological - While a chronological approach works, it may not be the most engaging approach. For example, if a person posts 30 times within the last hour, his followers will have their news feed clogged up with his posts. Maybe set a cap on the number of time a person's posts can appear within the feed.
- - Popularity - How many likes and comments does the post have? Does the user usually like posts by that person?
-- How do you determine which are the more important posts? A user might be more interested in a few-hour old post from a good friend than a very recent post from an acquaintance.
-- A common strategy is to calculate a post score based on various features and rank posts by its score.
-- Prior to 2013, Facebook was using the [EdgeRank](https://www.wikiwand.com/en/EdgeRank) algorithm to determine what articles should be displayed in a user's News Feed.
-- Edge Rank basically is using three signals: affinity score, edge weight and time decay.
- - Affinity score (u) - For each news feed, affinity score evaluates how close you are with this user. For instance, you are more likely to care about feed from your close friends instead of someone you just met once.
- - Edge weight (e) - Edge weight basically reflects importance of each edge. For instance, comments are worth more than likes.
- - Time decay (d) - The older the story, the less likely users find it interesting.
-- Affinity score
- - Various factors can be used to reflect how close two people are. First of all, explicit interactions like comment, like, tag, share, click etc. are strong signals we should use. Apparently, each type of interaction should have different weight. For instance, comments should be worth much more than likes.
- - Secondly, we should also track the time factor. Perhaps you used to interact with a friend quite a lot, but less frequent recently. In this case, we should lower the affinity score. So for each interaction, we should also put the time decay factor.
-- A good ranking system can improve some core metrics - user retention, ads revenue, etc.
-
-## Feed Publishing
-
-TODO. Refer to http://blog.gainlo.co/index.php/2016/04/05/design-news-feed-system-part-2/.
-
-## Additional Features
-
-#### Tagging feature
-
-- Have a `tags` table that stores the relation between a post and the people tagged in it.
-
-#### Sharing feature
-
-- Add a column to `posts` table called `original_post_id`.
-- What should happen when the original post is deleted?
- - The shared `posts` have to be deleted too.
-
-#### Notifications feature
-
-- When should notifications happen?
-- Can the user subscribe to only certain types of notifications?
-
-#### Trending feature
-
-- What constitutes trending? What signals would you look at? What weight would you give to each signal?
-- Most frequent hashtags over the last N hours.
-- Hottest search queries.
-- Fetch the recent most popular feeds and extract some common words or phrases.
-
-#### Search feature
-
-- How would you index the data?
-
-## Scalability
-
-- Master-slave replication.
- - Write to master database and read from replica databases/in-memory data store.
- - Post contents are being read more than they are updated. It is acceptable to have a slight lag between a user updating a post and followers seeing the updated content. Tweets are not even editable.
-- Data for real-time queries should be in memory, disk is for writes only.
-- Pre-computation offline.
-- Tracking number of likes and comments.
- - Expensive to do a `COUNT` on the `likes` and `comments` for a post.
- - Use Redis/Memcached for keeping track of how many likes/comments a post has. Increment when there's new activity, decrement when someone unlikes/deletes the comment.
-- Load balancer in front of your API servers.
-- Partitioning the data.
-
-###### References
-
-- [Design News Feed System (Part 1)](http://blog.gainlo.co/index.php/2016/03/29/design-news-feed-system-part-1-system-design-interview-questions/)
-- [Design News Feed System (Part 1)](http://blog.gainlo.co/index.php/2016/04/05/design-news-feed-system-part-2/)
-- [Etsy Activity Feeds Architecture](https://www.slideshare.net/danmckinley/etsy-activity-feeds-architecture)
-- [Big Data in Real-Time at Twitter](https://www.slideshare.net/nkallen/q-con-3770885)
diff --git a/design/search-engine.md b/design/search-engine.md
deleted file mode 100644
index 4703313bb..000000000
--- a/design/search-engine.md
+++ /dev/null
@@ -1,6 +0,0 @@
-Search Engine
-==
-
-###### References
-
-- [How Do Search Engines Work?](http://www.makeuseof.com/tag/how-do-search-engines-work-makeuseof-explains/)
diff --git a/domain/async-loading/index.html b/domain/async-loading/index.html
deleted file mode 100644
index d422c0c6e..000000000
--- a/domain/async-loading/index.html
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
-
-