From df1c15de0564f81a3c08d686f86b903efb7887f1 Mon Sep 17 00:00:00 2001 From: Jorge Gonzalez Date: Wed, 18 Oct 2017 10:25:39 -0400 Subject: [PATCH 01/20] Add two-stack-queue problem (#57) --- algorithms/queue.md | 1 + 1 file changed, 1 insertion(+) diff --git a/algorithms/queue.md b/algorithms/queue.md index 7710f991..31612de9 100644 --- a/algorithms/queue.md +++ b/algorithms/queue.md @@ -2,3 +2,4 @@ Queue == - Implement a Queue class from scratch with an existing bug, the bug is that it cannot take more than 5 elements. +- Implement a Queue using two stacks. You may only use the standard `push()`, `pop()`, and `peek()` operations traditionally available to stacks. You do not need to implement the stack yourself (i.e. an array can be used to simulate a stack). From 5d9002d7865c9efe2f8abd9c6a36432934bdf400 Mon Sep 17 00:00:00 2001 From: rishabhjain1996 Date: Wed, 18 Oct 2017 20:56:24 +0530 Subject: [PATCH 02/20] Update stack.md (#58) * Update stack.md * Update stack.md --- algorithms/stack.md | 1 + 1 file changed, 1 insertion(+) diff --git a/algorithms/stack.md b/algorithms/stack.md index 627ee2c6..063e3a64 100644 --- a/algorithms/stack.md +++ b/algorithms/stack.md @@ -6,3 +6,4 @@ Stack - Write an algorithm to determine if all of the delimiters in an expression are matched and closed. - E.g. `{ac[bb]}`, `[dklf(df(kl))d]{}` and `{[[[]]]}` are matched. But `{3234[fd` and `{df][d}` are not. - [Source](http://blog.gainlo.co/index.php/2016/09/30/uber-interview-question-delimiter-matching/) +- Sort a stack in ascending order using an additional stack. From 7154f2ca8e4e6448836a9d43f5a76946c3336c6f Mon Sep 17 00:00:00 2001 From: Mikun Pham Date: Thu, 19 Oct 2017 12:13:49 +0700 Subject: [PATCH 03/20] Fix js highlight (#59) --- front-end/interview-questions.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/front-end/interview-questions.md b/front-end/interview-questions.md index 9630684c..97d30471 100644 --- a/front-end/interview-questions.md +++ b/front-end/interview-questions.md @@ -713,7 +713,7 @@ A closure is the combination of a function and the lexical environment within wh They can be used in IIFEs to encapsulate some code within a local scope so that variables declared in it do not leak to the global scope. -``` +```js (function() { // Some code here. })(); @@ -721,7 +721,7 @@ They can be used in IIFEs to encapsulate some code within a local scope so that As a callback that is used once and does not need to be used anywhere else. The code will seem more self-contained and readable when handlers are defined right inside the code calling them, rather than having to search elsewhere to find the function body. -``` +```js setTimeout(function () { console.log('Hello world!'); }, 1000); @@ -729,7 +729,7 @@ setTimeout(function () { Arguments to functional programming constructs or Lodash (similar to callbacks). -``` +```js const arr = [1, 2, 3]; const double = arr.map(function (el) { return el * 2; @@ -923,7 +923,7 @@ These days, [CORS](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) i Yes. Handlebars, Underscore, Lodash, AngularJS and JSX. I disliked templating in AngularJS because it made heavy use of strings in the directives and typos would go uncaught. JSX is my new favourite as it is closer to JavaScript and there is barely and syntax to be learnt. Nowadays, you can even use ES2015 template string literals as a quick way for creating templates without relying on third-party code. -``` +```js const template = `
My name is: ${name}
`; ``` @@ -933,7 +933,7 @@ However, do beware of a potential XSS in the above approach as the contents are 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; @@ -947,7 +947,7 @@ 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' @@ -973,7 +973,7 @@ When an event triggers on a DOM element, it will attempt to handle the event if 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 @@ -981,7 +981,7 @@ 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! ``` From 4bb406a7de54ec717809b23f3af3aeebc298d90a Mon Sep 17 00:00:00 2001 From: Yes Man Date: Wed, 18 Oct 2017 22:49:13 -0700 Subject: [PATCH 04/20] Removed the in jsonp answer. (#60) --- front-end/interview-questions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front-end/interview-questions.md b/front-end/interview-questions.md index 97d30471..8b6c44e4 100644 --- a/front-end/interview-questions.md +++ b/front-end/interview-questions.md @@ -891,7 +891,7 @@ The `XMLHttpRequest` API is frequently used for the asynchronous communication o JSONP (JSON with Padding) is a method commonly used to bypass the cross-domain policies in web browsers because Ajax requests from the current page to a cross-origin domain is not allowed. -JSONP works by making a request to a cross-origin domain via a `