Problem Solving : Two-Sum and Three-Sum Problem
Problem Solving : Two-Sum and Three-Sum Problem
Problem Solving : Two-Sum and Three-Sum Problem

UPDATE : The Article currently contains Brute-Force Approaches for Three-sum Problem, Will update the better approaches soon.

I have started exploring Advent of Code for the year 2020. For Day 1, The scenario included writing a program to find the product of ’n’ numbers that add up to the given target sum value. So, Ideally finding those two/three elements is the key. This Article explains various ways you can achieve this.

Problem Statement for Two sum Problem

Given an array of integers and an integer , return two numbers such that they add up to .

For example, suppose your sample input contained the following and the target sum provided is…


Image for post
Image for post
Node.js Tutorial For Beginners : Part -1

Node.js is an open source, cross-platform, asynchronous event-driven JavaScript runtime. Node.js can be used to write command line tools and server-side scripts outside of a browser. It is designed to build scalable network applications. You need to use JavaScript programming language to code in Node.js.

How to install ?

To get started with Node.js development, you must first download and install Node.js in your system.

Approach 1 :

The first approach to install Node.js is simple and straight forward. You must visit The official Node.js website and follow the installation instructions here : https://nodejs.org

Approach 2 :

Alternatively, if you are interested in installing Node.js using NVM (node version manager) you must first install NVM . To do so, follow instructions in below…


Image for post
Image for post
Building CRUD api’s using Deno and oak

Deno is fairly new environment compared to Node. One of the first thing that a developer would want to do while learning Deno is to build CRUD api’s. Deno has several several projects which help us achieve this namely, deno-express, oak, servest, deno-drash,and pogo. In this article we will learn about building a todo list using Deno and Oak.

What are we building?

Oak is project that has been inspired by Koa, a popular Node.js HTTP middle-ware framework. We will use oak and Deno to build a small application which will deal with todos list. …


Image for post
Image for post
Deno : Overview and Creating your first local server

Deno is a secure runtime for JavaScript and TypeScript. It aims to provide a productive and secure scripting environment for the modern programmer. It is built on top of V8, Rust, and TypeScript. It was created to address several shortcomings of Node JS namely,

· Address the design shortcomings.

· Make use of promises in a better way.

· Address security issues (remember in a Node program you have access to system calls)

· The usage of Build System — GYP

· Usage of package.json and node_modules to allow to store all node_modules and their sub-modules rather than absolute import of specific sub-module alone. …


Image for post
Image for post
Introduction to Dynamic Programming — Memoization

Dynamic Programming simply means optimization of your code over plain recursion. The idea is to store the results of sub-problem and reuse it later when needed to do same calculations.

Let’s see how Dynamic Programming makes its program more efficient by using Memoization. We will write finding “n-th” Fibonacci Number programme to achieve this.

Fibonacci Problem — General Approach

Following diagram shows the general way most of us approach solving Fibonacci Number Problem. Here we have a function fib(n) which accept a parameter “n” and gives the output of n-th element in fibonacci series.


How to build a simple JavaScript module and publish it to the npm registry

Pre-requisites

  1. npm account, if you don’t have one sign up here.
  2. Node installed in your machine.
  3. Login to npm using command prompt using one of the following commands, you will be prompted with usename, password and email address.

or

Creating a simple package

Lets’ create a simplest code by running following commands sequentially.

Create a file called index.js and copy the following content.

const chalk = require('chalk');class Log {    info({ msg = "", data = "" }) {
console.log(`"${chalk.green(msg)}", "${data}" was posted on "${Date()}" with status ${chalk.green('✓')}`)
}
error({ msg = "", data = "" }) {
console.log(`"${chalk.red(msg)}", "${data}" was posted on "${Date()}" with status ${chalk.red('X')}`)…


Image for post
Image for post
Webpack 4.2, React 16.9 and babel 7.3

This article helps in understanding how the “create-react-app” command works behind the scene. You can build a react application from the scratch using webpack, babel and react libraries.

Steps that you should follow to build a React application from scratch.

Open the command prompt and start executing the following commands sequentially.

1. mkdir webpack-bolier-plate

2. cd webpack-bolier-plate

3. npm init -y

4. npm install react react-dom

5. npm install --save-dev @babel/core @babel/preset-env @babel/preset-react css-loader html-webpack-plugin style-loader webpack webpack-cli webpack-dev-server babel-loader

Manipulation of Files.

  1. Now create a file named webpack.config.js
  2. The following lines help to bundle all modules in app into single file. …


Image for post
Image for post
Hosting React application on azure app service.

Azure App Service is a PaaS that allows you to host web, mobile apps, web API’s and logic apps.This article explains about how to host your react app on azure app service. Assuming you have npm and VS Code installed in your machine, follow below steps sequentially.

  1. Open VS Code terminal.

2. Create a react app by running ‘npx create-react-app my-app‘ command.

3. The folder structure of the app should look like this.

About

Kailas Walldoddi

Fullstack Developer. Loves to write about Javascript, React.js, Node.js , Cloud Platforms.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store