Object Oriented Programming Articles

Page 59 of 589

Common Character Count in Strings in JavaScript

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

In JavaScript, finding common characters between two strings involves counting how many characters appear in both strings. This is useful for text analysis, similarity comparisons, and string manipulation tasks. Understanding the Problem The goal is to count common characters between two strings, considering frequency. For example, if we have "abaac" and "baaaa", the common characters are 'a' (appears 3 times in first string, 4 times in second, so we count 3) and 'b' (appears 1 time in both, so we count 1), giving us a total of 4 common characters. Algorithm Step 1: Create a function ...

Read More

Comparing integers by taking two numbers in JavaScript

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

Comparing integers is a fundamental operation in JavaScript programming. This tutorial demonstrates how to compare two integers and determine their relationship using JavaScript's comparison operators. Understanding the Problem Integer comparison involves determining the relationship between two numbers - whether one is greater than, less than, or equal to another. This operation is essential for sorting algorithms, conditional logic, and data validation. For example, comparing 15 and 10 tells us that 15 is greater than 10. Comparison Operators in JavaScript ...

Read More

Convert string with separator to array of objects in JavaScript

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

In this article, we'll learn how to convert a string with separators into an array of objects using JavaScript's built-in methods. This is a common data transformation task when working with CSV-like data or user input. Understanding the Problem We need to transform a string like "name1, name2, name3" with separator ", " into an array of objects: [{value: "name1"}, {value: "name2"}, {value: "name3"}] Each substring becomes an object with a value property containing the original string segment. Algorithm Step 1: Split the input string using the separator to create an array ...

Read More

Cumulative sum at each index in JavaScript

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

In JavaScript, calculating the cumulative sum (also known as running sum or prefix sum) at each index means computing the sum of all elements from the beginning of the array up to the current position. This is a common array operation used in algorithms and data analysis. What is Cumulative Sum? The cumulative sum is the calculation of the sum of a series of numbers up to a given index. Each element in the resulting array represents the sum of all previous elements including the current element. For example, given an array [1, 2, 3, 4, 5], ...

Read More

Factorize a number in JavaScript

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

In JavaScript, factorizing a number means finding all the prime factors that multiply together to form the original number. This is a fundamental mathematical operation used in cryptography, number theory, and various algorithms. Understanding Prime Factorization Prime factorization breaks down a number into its basic building blocks - prime numbers. For example, 36 = 2 × 2 × 3 × 3, where 2 and 3 are prime factors. We need to find all prime numbers that divide the given number without leaving a remainder. Algorithm Approach The efficient approach iterates from 2 to the square root ...

Read More

Find the Exact Individual Count of Array of String in Array of Sentences in JavaScript

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

In JavaScript, you often need to count how many times specific strings appear in an array of sentences. This article demonstrates how to find the exact individual count of each string from a given array within multiple sentences using regular expressions and word boundaries. Understanding the Problem Given an array of strings and an array of sentences, we need to count how many times each string appears across all sentences. The key requirement is to match complete words only, not partial matches within other words. ...

Read More

Find the greatest product of three numbers in JavaScript

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

In JavaScript, finding the greatest product of three numbers from an array requires considering both positive and negative numbers. This problem has multiple approaches, from brute force to optimized sorting methods. Understanding the Problem Given an array of integers, we need to find three numbers whose product is the largest among all possible combinations. For example, with array [1, 5, 3, 2, 4], the three largest numbers (3, 4, 5) give us the product 3 × 4 × 5 = 60. ...

Read More

Find the largest palindrome number made from the product of two n digit numbers in JavaScript

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

In this problem, we need to find the largest palindrome number that can be created by multiplying two n-digit numbers using JavaScript. We'll implement two functions: one to find the largest palindrome product and another to check if a number is palindromic. What are Palindrome Numbers? A palindrome number reads the same forwards and backwards. Examples include 44, 121, 202, 404, and 909. When reversed, these numbers remain identical to their original form. Understanding the Problem We need to find the largest possible palindrome that results from multiplying two n-digit numbers. For example, with 2-digit numbers ...

Read More

Finding all duplicate numbers in an array with multiple duplicates in JavaScript

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

In JavaScript, finding duplicate numbers in an array is a common task that can be efficiently solved using objects to track element frequencies. This approach helps identify all numbers that appear more than once in the array. Understanding the Problem We need to find all duplicate numbers in an array that may contain multiple duplicates. For example, given the array [1, 1, 4, 8, 2, 2, 6, 6, 6], the duplicate numbers are [1, 2, 6] since these appear more than once. Using Object to Count Frequencies The most efficient approach uses an object to count ...

Read More

Finding all the Longest Strings from an Array in JavaScript

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

In the given problem statement we have to find all the longest strings from an array with the help of JavaScript functionalities. This task can be done by getting the length of each string and then comparing these lengths with the maximum length. Understanding the Problem The problem is to find all the longest strings from an array in JavaScript. We have an array of strings and our task is to identify the strings with maximum length and return them as a new array. For example: if we have an array ['abc', 'defg', 'hijkl', 'mnopqr', 'stuvwxyz'], the longest ...

Read More
Showing 581–590 of 5,881 articles
« Prev 1 57 58 59 60 61 589 Next »
Advertisements