Instantly share code, notes, and snippets.

📡
contacting aliens

# Anthony Attardanthonyattard

📡
contacting aliens
• Sort options
Last active Aug 13, 2019
Two Pointer - Container with Most Water
View two-pointer-container-with-most-water.md

Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water. From https://leetcode.com/problems/container-with-most-water/

Algorithm

The intuition behind this approach is that the area formed between the lines will always be limited by the height of the shorter line. Further, the farther the lines, the more will be the area obtained.

We take two pointers, one at the beginning and one at the end of the array constituting the length of the lines. Futher, we maintain a variable maxarea to store the maximum area obtained till now. At every step, we find out the area formed between them, update maxarea and move the pointer pointing to the shorter line towards the other end by one step.

How this approach works?

Created Apr 24, 2018 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date
View Keeping a fork up to date.md

### 1. Clone your fork:

``````git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git
``````

### 2. Add remote from original repository in your forked repository:

``````cd into/cloned/fork-repo
git fetch upstream
``````
Last active Aug 13, 2019
ShoeMagoo Quiz
View shoemagoo-quiz.md
```function greeting(\$hello = false) {
if(\$hello === true) {
echo("hello");
} else {
echo("bye");
}
}```
Last active Aug 13, 2019
View File Permissions with Code
View View File Permissions with Code.md

`stat -f "%N %OLp" *`

Last active Aug 13, 2019 — forked from PurpleBooth/README-Template.md