Nikitasha Shrivastava

Nikitasha Shrivastava

163 Articles Published

Articles by Nikitasha Shrivastava

Page 2 of 17

Implementing counting sort in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 2K+ Views

In the given task, our aim is to create a counting sorting technique and implement this problem with the help of Javascript functionalities. What is Counting Sort? Counting sort is a non-comparison based sorting algorithm that works by counting the occurrences of each distinct element in the input array. It determines the position of each element in the sorted output by calculating how many elements are smaller than it. The algorithm works in several phases: Find the minimum and maximum values in the input array Create a count array to ...

Read More

Function to find out palindrome strings JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 250 Views

In this problem statement, our aim is to create a function to find out that the given string is palindrome with the help of Javascript functionalities. So for solving this problem first we need to understand the problem in simple terms. Understanding the Problem Statement We have given a string as an input string and our main aim is to check if the string is a palindrome string or not. If it is palindrome then return true otherwise return false. What is a Palindrome? A palindrome is a string that reads the same forwards and backwards. ...

Read More

Checking for string anagrams JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 406 Views

In this problem statement, our aim is to check for string anagrams with the help of Javascript functionalities. So for solving this problem first we need to understand the problem in simple terms. Understanding the Problem Statement We have given two strings as input and our main aim is to check if the strings are anagrams of each other. If they are anagrams then return true otherwise return false. What are Anagrams? An anagram is a word or phrase formed by rearranging the letters of another word or phrase, using all the original letters exactly once. ...

Read More

Reversing the words within keeping their order the same JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 1K+ Views

In JavaScript, we can reverse each word in a string while maintaining their original positions. This means "Hello World" becomes "olleH dlroW" - each word is reversed individually, but their order remains unchanged. Understanding the Problem We need a function that takes a string and returns a new string where each word is reversed, but the word positions stay the same. For example: Input: "Hello World" Output: "olleH dlroW" The word order is preserved, but each word's characters are reversed. Method 1: Using Built-in Methods (Recommended) The most efficient approach uses JavaScript's ...

Read More

Sort an integer array, keeping first in place in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 324 Views

In JavaScript, when you need to sort an integer array while keeping the first element in its original position, you can combine array slicing with the built-in sort method. This approach preserves the first element while sorting the remaining elements. Understanding the Problem The task is to sort an integer array in ascending order while keeping the first element at index 0. For example, if you have an array [4, 7, 8, 5, 6, 1, 3], the result should be [4, 1, 3, 5, 6, 7, 8] ...

Read More

Spiraling the elements of a square matrix JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 348 Views

In this problem statement, our main aim is to spiral the elements of a square matrix with the help of JavaScript functionalities. We'll traverse the matrix in a clockwise direction, starting from the top-left corner and moving in a spiral pattern. Understanding the Problem The problem is to write a function in JavaScript that converts a 2D matrix into a 1D array by traversing elements in a clockwise spiral pattern. For example, if we have a matrix: [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] ...

Read More

Finding sum of multiples in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 2K+ Views

In JavaScript, finding the sum of multiples of a given number within a specific range is a common programming problem. We need to identify all numbers divisible by the input number and calculate their sum using loops and conditional checks. Understanding the Problem The task is to find the sum of all multiples of a given number within a specified range. A multiple is any number that can be divided evenly by the given number (remainder is zero). For example: if we have number 3 and range 1 to 12, the multiples of 3 are: 3, 6, ...

Read More

Using Sieve of Eratosthenes to find primes JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 2K+ Views

In this article, we'll implement the Sieve of Eratosthenes algorithm in JavaScript to efficiently find all prime numbers up to a given limit. This classical algorithm is much faster than checking each number individually for primality. What is the Sieve of Eratosthenes Algorithm? The Sieve of Eratosthenes is an ancient and efficient algorithm for finding all prime numbers up to a given range. It works by creating a list of all numbers from 2 to the target number, then systematically eliminating the multiples of each prime number, leaving only the primes. Sieve of ...

Read More

Sum of even Fibonacci terms in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 644 Views

In this article, we'll learn how to calculate the sum of even Fibonacci numbers using JavaScript. The Fibonacci sequence is a series where each number is the sum of the two preceding ones, usually starting with 0 and 1. Understanding the Problem The Fibonacci sequence starts as: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55... Our task is to find all even Fibonacci numbers up to a given limit and calculate their sum. For example, if the limit is 35, the Fibonacci numbers within ...

Read More

Absolute Values Sum Minimization in JavaScript

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 15-Mar-2026 676 Views

In JavaScript, finding the value that minimizes the sum of absolute differences from all elements in an array is a fundamental optimization problem. The optimal solution is to find the median of the array. Understanding the Problem Given an array of numbers, we need to find a value x that minimizes the sum of |arr[i] - x| for all elements in the array. Mathematically, this optimal value is always the median of the sorted array. Sum Minimization Concept 1 ...

Read More
Showing 11–20 of 163 articles
« Prev 1 2 3 4 5 17 Next »
Advertisements