Nginx

Nginx is a web server that can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache. It started out as a web server designed for maximum performance and stability.

Installing Nginx using Homebrew

Homebrew — Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple’s operating system.

Step- 1 Installing Homebrew
Run below command in terminal

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Step -2 Update Homebrew
Run below command in terminal

brew update

Step -3 Install Nginx
Run below command in terminal

brew install nginx

Step -4 Validate Nginx installation
Run below command in terminal

nginx

It will start the web server.

Happy Learning…. 🙏🙏🙏

--

--

Two Number Sum

Problem- Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to the target.

Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Input: nums = [3,2,4], target = 6
Output: [1,2]

Solution 1(Good)

const twoSum = function (nums, target) {let temMap = {};if (nums?.length < 2) {return null;}for (let i = 0; i < nums.length; i++) {const index = target — nums[i];if (temMap[index] !=null ) {return [temMap[index],i]}if (!temMap[nums[i]]) {temMap[nums[i]] = i;}}return null;};

Solution 2(Just Ok)

const twoSum = function (nums, target) {if(nums?.length <2){return null}else{for(let i=0; i<=nums.length; i++){for(let j= i+1; j<=nums.length; j++){if(nums[i] + nums[j] ===target){return [i, j]}}}}return null};

Happy Learning ….👏👏👏

--

--

Anil Verma

Anil Verma

22 Followers

Hi there 👋, I am Anil Verma, a full stack web developer, and JavaScript enthusiast. 👥 Ask me anything about web development. 📖 Love to read and write.