xxxxxxxxxx
After installing brew from brew.sh
#install
brew tap mongodb/brew
brew install mongodb-community
#setup database directory
sudo mkdir -p /System/Volumes/Data/data/db
sudo chown -R `id -un` /System/Volumes/Data/data/db #if no errors good to go
#tell mongo new db path
sudo mongod --dbpath /System/Volumes/Data/data/db
mongo
mongod
xxxxxxxxxx
#Install xcode command line tools if you don't have
xcode-select --install
#Install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
#Install mongodb
brew tap mongodb/brew
brew update
brew install mongodb-community@5.0
mongodb community edition install on mac m1
xxxxxxxxxx
1: xcode-select --install
2: brew tap mongodb/brew
3: brew install mongodb-community@6.0
4: brew services start mongodb-community@6.0
5: brew services stop mongodb-community@6.0
xxxxxxxxxx
/*
You are given an integer array heights where heights[i] represents the
height of the i(th) bar.
You may choose any two bars to form a container. Return the maximum amount
of water a container can store.
Example 1:
Input: height = [1,7,2,5,4,7,3,6]
Output: 36
Example 2:
Input: height = [2,2,2]
Output: 4
*/
const maxArea = heights => {
let [left, right, maxContainer] = [0, heights.length - 1, -Infinity]
if(heights.length <= 2) return Math.min(heights[left], heights[right])
else{
while(left < right){
const [leftValue, rightValue] = [heights[left], heights[right]]
const [minValue, containersHeldLength] =
[Math.min(leftValue, rightValue), heights.slice(left, right + 1).length - 1]
const valueProd = minValue * containersHeldLength
valueProd > maxContainer ?
maxContainer = valueProd : null
leftValue > rightValue ?
right-- : left++
}
}
return maxContainer
}
const heights = [1,7,2,5,12,3,500,500,7,8,4,7,3,6]
const result = maxArea(heights)
console.log(result) // Output: 500
// With love @kouqhar