AmitDiwan has Published 10744 Articles

Any possible combination to add up to target in JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Mar-2021 13:34:40

346 Views

ProblemWe are required to write a JavaScript function that takes in an array of unique integers, arr, as the first argument, and target sum as the second argument.Our function should count the number of all pairs (with repetition allowed) that can add up to the target sum and return that ... Read More

Finding a number of pairs from arrays with smallest sums in JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Mar-2021 13:32:48

222 Views

ProblemWe are required to write a JavaScript function that takes in two sorted arrays of Integers as the first and the second argument respectively, arr1 and arr2.The third argument to the function will be a number, num, and num will always be lesser than the length of both the arrays. ... Read More

Largest rectangle sum smaller than num in JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Mar-2021 13:31:19

140 Views

ProblemWe are required to write a JavaScript function that takes in a 2-D array of Numbers as the first argument and a target sum number as the second argument.Our function should find out that rectangle from the 2-D array which has the greatest sum among all rectangles in the array ... Read More

Killing Enemy in JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Mar-2021 13:29:53

287 Views

ProblemSuppose, we have a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero). We are required to write a function that returns the maximum enemies we can kill using only one bomb.The bomb kills all the enemies in the same row ... Read More

Applying f(x) to each array element in JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Mar-2021 13:28:17

143 Views

ProblemSuppose, a mathematical function given by −f(x) = ax2 + bx + cWhere a, b and c are three constants.We are required to write a JavaScript function that takes in a sorted array of Integers, arr as the first argument and a, b and c as second, third and fourth ... Read More

Placing same string characters apart in JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Mar-2021 13:25:32

161 Views

ProblemWe are required to write a JavaScript function that takes in a string of characters, str, as the first argument and a number, num, (num {    const map = {};    for(let i=0; i{       if(map[a] len){       return "";    };    const ... Read More

Counting n digit Numbers with all unique digits in JavaScript

AmitDiwan

AmitDiwan

Updated on 18-Mar-2021 13:23:20

288 Views

ProblemWe are required to write a JavaScript function that takes in a number, let’s say num, as the only argument. The function should count all such numbers that have num digits and all of their digits are unique.For example, if the input to the function is −const num = 1;Then ... Read More

Deleting desired node from a Binary Search Tree in JavaScrip

AmitDiwan

AmitDiwan

Updated on 18-Mar-2021 08:45:50

264 Views

ProblemSuppose, we have the following code that creates a Binary Search Tree DS and provides us with the functionality to insert node −class Node{    constructor(data) {       this.data = data;       this.left = null;       this.right = null;    }; }; class BinarySearchTree{ ... Read More

Creating a Page with Sidebar and Main Content Area using HTML & CSS

AmitDiwan

AmitDiwan

Updated on 13-Mar-2021 12:20:21

2K+ Views

A webpage with fluid sidebar and main content area is created by setting the size of html and body to 100%.The following example illustrates this.Example Live Demo html, body {    height: 100%;    color: white;    font-size: 2em;    line-height: 200px; } #parent {    display: table; ... Read More

Creating a Full Height Page with Fixed Sidebar and Scrollable Content Area in CSS

AmitDiwan

AmitDiwan

Updated on 13-Mar-2021 12:19:13

6K+ Views

A full-height page with a fixed sidebar and scrollable content area can be created by setting the height to 100% and applying proper positioning of elements.The following example illustrates the above.Example Live Demo .main {    margin-left: 140px;    font-size: 200%;    padding: 0 3%; } section { ... Read More

Advertisements