Found 8894 Articles for Front End Technology

Removing already listed intervals in JavaScript

AmitDiwan
Updated on 07-Apr-2021 09:20:49

115 Views

ProblemJavaScript function that takes in a 2-D array, arr, as the first and the only argument.Each subarray of our input array is an array of exactly two numbers, specifying a time interval.Our function should remove all intervals that are covered by another interval in the array arr. Interval [a,b) is covered by interval [c,d) if and only if c (a === c ? d - b : a - c));    let last = arr[0];    let count = arr.length;    for(let i = 1; i < arr.length; i++){       const [a, b] = last;       const [c, d] = arr[i];       if(c >= a && d

Path with smallest sum in JavaScript

AmitDiwan
Updated on 07-Apr-2021 07:26:18

207 Views

ProblemJavaScript function that takes in a 2-D array of numbers as the first and the only argument.Our function should find paths from the 2-D array by picking exactly one element from each row, and no two elements picked from adjacent rows should be in the same column. Out of all these paths, our function should return the sum of that path that has the minimum sum.For example, if the input to the function is −const arr = [    [4, 7, 1],    [2, 8, 3],    [5, 6, 9] ]Then the output should be −const output = 9;Output ExplanationBecause ... Read More

Difference Between GET and POST Method in HTML

AmitDiwan
Updated on 23-Mar-2021 07:30:17

4K+ Views

In this post, we will understand the difference between GET and POST methods in HTML.GET MethodThe parameters are placed inside the URL.Its main goal is to retrieve the data/documents present inside it.It has the ability to bookmark the results of the query.It is vulnerable, and not secure enough.This is because the data and credentials are present as plain text.It can be seen by anyone.The data constraint is that only ASCII characters are allowed.It can be up to 2000 characters only.It is also said to keep the length of the data to a minimum value.Data can be cached when GET method ... Read More

Difference Between XML and HTML

AmitDiwan
Updated on 21-Dec-2021 07:38:09

630 Views

In this post, we will understand the difference between HTML and XML.HTMLIt refers to Hyper Text Markup Language.It helps create web pages and applications.It is a markup language.It helps create static pages as well.It helps display data.It doesn’t transport data.HyperText helps define link between multiple web pages.Markup Language helps define text document using tags, which gives a structure to the web page.It helps annotate the text so that a system can understand it and use it.It ignores minor errors.It is not case sensitive.There are specific number of tags in HTML.These tags are predefined.It doesn’t preserve white spaces.Closing tags are not ... Read More

Super Ugly Numbers JavaScript

AmitDiwan
Updated on 20-Mar-2021 05:46:18

123 Views

Super Ugly NumberSuper ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k. For example, [1, 2, 4, 7, 8, 13, 14, 16, 19, 26, 28, 32] is the sequence of the first 12 super ugly numbers given primes = [2, 7, 13, 19] of size 4.ProblemWe are required to write a JavaScript function that takes in number, num, as the first argument and an array, arr, of prime numbers as the second argument. The function should find and return the (num)th super ugly number.ExampleThe code for this will be −const ... Read More

Counting smaller numbers after corresponding numbers in JavaScript

AmitDiwan
Updated on 20-Mar-2021 05:43:50

137 Views

ProblemWe are required to write a JavaScript function that takes in an array of Numbers as the first and the only argument.Our function should prepare a new array based on the input array. And each corresponding element of this new array should be the count of elements smaller than the corresponding element in the original array.For example, if the input to the function is −const arr = [4, 7, 1, 4, 7, 5, 3, 8, 9];Then the output should be −const output = [2, 4, 0, 1, 2, 1, 0, 0, 0];Output Explanation:Because number smaller than 4 to its right ... Read More

Limiting duplicate character occurrence to once in JavaScript

AmitDiwan
Updated on 20-Mar-2021 05:42:10

122 Views

ProblemWe are required to write a JavaScript function that takes in a string, str, as the only argument.The function should prepare a new string based on the input string in which the only one appearance of each character is kept and the character kept is the one which makes the result string lexicographically the smallest.For example, if the input to the function is −const str = 'cbacdcbc';Then the output should be −const output = 'acdb';Output Explanation:Note that we could have removed any occurrence of ‘c’ from the string but we removed the very first, which makes the string lexicographically the ... Read More

Maximum length product of unique words in JavaScript

AmitDiwan
Updated on 20-Mar-2021 05:39:40

77 Views

ProblemWe are required to write a JavaScript function that takes in an array of strings (only lowercase string alphabets) as the first and the only argument.The function should pick two such strings from the array that shares no common characters and have the maximum product of their lengths. And then our function should return the length product of two such strings. If there exist no such strings in the array, we should return 0.For example, if the input to the function is −const arr = ["karl", "n", "the", "car", "mint", "alpha"];Then the output should be −const output = 20;Output Explanation:The ... Read More

Switching on and off bulb in JavaScript

AmitDiwan
Updated on 20-Mar-2021 05:37:36

490 Views

ProblemConsider this following situation −There are n bulbs that are initially off. We first turn on all the bulbs. Then, we turn off every second bulb. On the third round, we toggle every third bulb (turning on if it's off or turning off if it's on).In general, for the ith round, we toggle every i bulb. And lastly for the nth round, we only toggle the last bulb.We are required to write a JavaScript function that takes n as the only input and finds out how many bulbs are on after n rounds.For example, if the input to the function ... Read More

Finding maximum number from two arrays in JavaScript

AmitDiwan
Updated on 20-Mar-2021 05:35:27

506 Views

ProblemWe are required to write a JavaScript function that takes in two arrays of single digit numbers representing two numbers, arr1 and arr2 as the first and second argument. The third argument to the function will be a number, num (num {    const map = new Map();    const match = (a, b, num) => {       if (map.has(a + ', ' + b + ', ' + num)) {          return map.get(a + ', ' + b + ', ' + num);       }       let output = ... Read More

Advertisements