Articles on Trending Technologies

Technical articles with clear explanations and examples

crypto.createECDH() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 11-Mar-2026 518 Views

The crypto.createECDH() is used to create an elliptic curve also known as Elliptic Curve Diffie-Hellman i.e ECDH that uses a curve predefined by the input parameter curveName. You can use crypto.getCurves to get the list of all the available curve names. This method is part of the 'crypto' module.Syntaxcrypto.createECDH(curveName)ParametersThe above parameters are described as belowcurveName – It takes the input for the curve name. This curveName will deined the predefined curve for creating ECDH.ExampleCreate a file with name – createECDH.js and copy the below code snippet. After creating file, use the following command to run this code as shown in the ...

Read More

Python Program to Implement a Stack using Linked List

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 4K+ Views

When it is required to implement a stack data structure using a linked list, a method to add (push values) elements to the linked list, and a method to delete (pop values) the elements of the linked list are defined.Below is a demonstration for the same −Exampleclass Node:    def __init__(self, data):       self.data = data       self.next = None class Stack_structure:    def __init__(self):       self.head = None    def push_val(self, data):       if self.head is None:          self.head = Node(data)       else:   ...

Read More

Python Program to Find All Connected Components using DFS in an Undirected Graph

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 2K+ Views

When it is required to find all the connected components using depth first search in an undirected graph, a class is defined that contains methods to initialize values, perform depth first search traversal, find the connected components, add nodes to the graph and so on. The instance of the class can be created and the methods can be accessed and operations and be performed on it.Below is a demonstration of the same −Exampleclass Graph_struct:    def __init__(self, V):       self.V = V       self.adj = [[] for i in range(V)]    def DFS_Utililty(self, temp, v, ...

Read More

Counting prime numbers that reduce to 1 within a range using JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 199 Views

ProblemWe are required to write a JavaScript function that takes in a range array of two numbers. Our function should return the count of such prime numbers whose squared sum of digits eventually yields 1.For instance, 23 is a prime number and,22 + 32 = 13 12 + 32 = 10 12 + 02 = 1Hence, 23 should be a valid number.ExampleFollowing is the code −const range = [2, 212]; String.prototype.reduce = Array.prototype.reduce; const isPrime = (n) => {    if ( n acc+v*v, 0 )));    return n===1; } const countDesiredPrimes = ([a, b]) => {    let res=0;    for ( ; a

Read More

crypto.createSign() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 11-Mar-2026 387 Views

The crypto.createSign() will create and return a sign object tha uses the passed algorithm in the parameter. One can use, crypto.getHashes() to get the names of all the available digest algorithms. You can create a Sign instance by using the name of the signature algorithms such as 'RHA-SHA256' only in some of the cases, instead of a digest algorithm.Syntaxcrypto.createSign(algorithm, [options])ParametersThe above parameters are described as below −algorithm – It takes the input for the algorithm name to be used while creating the sign object/instance.options – This is an optional parameter that can be used for controlling the stream behaviour.ExampleCreate a file ...

Read More

Python Program to Implement Queue Data Structure using Linked List

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 2K+ Views

When it is required to implement a queue data structure using a linked list, a method to add (enqueue operation) elements to the linked list, and a method to delete (dequeue operation) the elements of the linked list are defined.Below is a demonstration for the same −Exampleclass Node:    def __init__(self, data):    self.data = data    self.next = None class Queue_structure:    def __init__(self):       self.head = None       self.last = None    def enqueue_operation(self, data):       if self.last is None:          self.head = Node(data)       ...

Read More

Sum of all positives present in an array in JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 2K+ Views

ProblemWe are required to write a JavaScript function that takes in an array of numbers (positive and negative). Our function should calculate and return the sum of all the positive numbers present in the array.ExampleFollowing is the code −const arr = [5, -5, -3, -5, -7, -8, 1, 9]; const sumPositives = (arr = []) => {    const isPositive = num => typeof num === 'number' && num > 0;    const res = arr.reduce((acc, val) => {       if(isPositive(val)){          acc += val;       };       return acc;    }, 0);    return res; }; console.log(sumPositives(arr));OutputFollowing is the console output −15

Read More

Reversing a string while maintaining the position of spaces in JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 853 Views

ProblemWe are required to write a JavaScript function that takes in a string that might contain some spaces.Our function should reverse the words present in the string internally without interchange the characters of two separate words or the spaces.ExampleFollowing is the code −const str = 'this is normal string'; const reverseWordsWithin = (str = '') => {    let res = "";    for (let i = str.length - 1; i >= 0; i--){       if(str[i] != " "){          res += str[i];       };       if(str[res.length] == " "){          res += str[res.length];       };    };    return res; }; console.log(reverseWordsWithin(str));Outputgnir ts lamron sisiht

Read More

crypto.createVerify() Method in Node.js

Mayank Agarwal
Mayank Agarwal
Updated on 11-Mar-2026 894 Views

The crypto.createVerify() will create and return a verify object that uses the passed algorithm in the parameter. One can use, crypto.getHashes() to get the names of all the available signing algorithms. You can create a Verify instance by using the name of the signature algorithms such as 'RHA-SHA256' only in some of the cases, instead of a digest algorithm.Syntaxcrypto.createVerify(algorithm, [options])ParametersThe above parameters are described as below −algorithm – It takes the input for the algorithm name to be used while creating the verify object/instance.options – This is an optional parameter that can be used for controlling the stream behaviour.ExampleCreate a file with ...

Read More

Removing consecutive duplicates from strings in an array using JavaScript

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 1K+ Views

ProblemWe are required to write a JavaScript function that takes in an array of strings. Our function should remove the duplicate characters that appear consecutively in the strings and return the new modified array of strings.ExampleFollowing is the code −const arr = ["kelless", "keenness"]; const removeConsecutiveDuplicates = (arr = []) => {    const map = [];    const res = [];    arr.map(el => {       el.split('').reduce((acc, value, index, arr) => {          if (arr[index] !== arr[index+1]) {             map.push(arr[index]);          }          if (index === arr.length-1) {             res.push(map.join(''));             map.length = 0          }       }, 0);    });    return res; } console.log(removeConsecutiveDuplicates(arr));Output[ 'keles', 'kenes' ]

Read More
Showing 1131–1140 of 61,248 articles
« Prev 1 112 113 114 115 116 6125 Next »
Advertisements