Found 9321 Articles for Object Oriented Programming

Merge two sorted arrays to form a resultant sorted array in JavaScript

AmitDiwan
Updated on 21-Nov-2020 10:30:47

148 Views

We are required to write a JavaScript function that takes in two sorted array of numbers. The function should merge the two arrays together to form a resultant sorted array and return that array.For example −If the two arrays are −const arr1 = [2, 6, 6, 8, 9]; const arr2 = [1, 4, 5, 7];Then the output array should be −const output = [1, 2, 4, 6, 6, 7, 8, 9];ExampleThe code for this will be −const arr1 = [2, 6, 6, 8, 9]; const arr2 = [1, 4, 5, 7]; const mergeSortedArrays = (arr1 = [], arr2 = []) ... Read More

JavaScript function to prepend string into all the values of array?

Sakshi Jain
Updated on 21-Aug-2023 17:01:31

506 Views

The problem statement says to perform a prepend string into all the values of array elements where the prepend string and array values will be given by the user as an input source. The problem statement can be deeply visualized as given a string text specifically to prepend or attach at the beginning of each element of the array , the output should return the new resultant array with prepended string value in combination with the value of array elements. What is an Array in JavaScript ? If you are familiar with any other programming language like C, C++, ... Read More

Inverting a binary tree in JavaScript

Sakshi Jain
Updated on 22-Aug-2023 18:40:45

554 Views

The problem statement asks the user that given a binary tree , you need to find the mirror image of the elements of the binary tree such that reverse the corresponding and parallel siblings of the tree branches . In short, invert the whole binary tree given the original binary tree as an input. The output of the problem statement looks like a reverse function of the input binary tree as the summary to implement for. What is a Tree in JavaScript A tree refers to one of the optimized data structures to hold data ... Read More

Add all records from one array to each record from a different array in JavaScript

Sakshi Jain
Updated on 22-Aug-2023 18:14:40

322 Views

The problem statement asks the user to add all the records from one array to each record from a different array in JavaScript , the just read statement seems tough to understand and implement code upon . The simplest meaning is given two arrays of different collections of values , we need to generate a combined new array of objects such that the new generated array is a collection of every possible of values present in both arrays for say array1 and array2. The problem statement can be implemented in another way too , saying to find the Cartesian ... Read More

Removing duplicates from a sorted array of literals in JavaScript

Sakshi Jain
Updated on 22-Aug-2023 18:49:22

201 Views

The problem statement says that given a sorted array of numbers as an input source by the user such that we need to remove the duplicates or repeated elements from it making it all new array containing only unique elements inside it. What is a Sorted Array in JavaScript ? A sorted array is a kind of array in javascript that follows a certain order of line in which each element is sorted in alphabetical and numerical order all before using the sort method in javascript itself. The already sorted speed array lets you speed up the ... Read More

Case-sensitive sort in JavaScript

Sakshi Jain
Updated on 22-Aug-2023 18:27:49

2K+ Views

The problem statement says to perform case sensitive sorting in javascript on the array of strings given as an input source by the user . The problem statement wants the developer to perform a case sensitive sorting where all the special characters and numerals should appear first and sort first inplace followed by the sorting of lowercase characters first before the upper case characters . Is JavaScript Case Sensitive ? Before moving forward towards the problem statement we need to understand more about the word “case-sensitive” in the context of JavaScript initially. JavaScript ... Read More

Can the string be segmented in JavaScript

Sakshi Jain
Updated on 22-Aug-2023 18:17:30

227 Views

The problem statement says to check if the string given by the user as an input can be segmented or not . What is a Segmented String ? Segmentation in string refers to breaking down words in the whole string text as an input . The words are broken down into the words of the dictionary. The problem statement is more established and dug deeper down into given some wholesome dictionaries of words and string text and we have to check if the segmented or broken down of string is compatible and equal to words of ... Read More

Finding Common Item Between Arbitrary Number of Arrays in JavaScript

Sakshi Jain
Updated on 22-Aug-2023 18:32:29

172 Views

The problem statement tells you to find a solution for an arbitrary number of arrays such that the user needs to find a common element present in every arbitrary array. The arbitrary array is referred to here as an object of arrays . One should not confuse finding common elements between two arrays , it is not what the problem statement is asking for. It defines and explores the variety of algorithms that can help us find the least common factors present in mutual by the given source data in JavaScript. What are Arbitrary Number of Arrays in ... Read More

Two sum problem in linear time in JavaScript

Sakshi Jain
Updated on 22-Aug-2023 19:07:24

2K+ Views

The problem statement says to execute Two sum problem in linear time in JavaScript. It defines and explores the variety of algorithms that can help us find the least common factors present in mutual by the given source data in JavaScript. What is the Two sum problem in JavaScript ? Two Sum Problem in JavScript equals finding a pair of indices present in the array of numbers given as an input that adds up to the target sum which is also provided as an input by the user. Given an array of integers and ... Read More

sorting array of numbers into sets in JavaScript

Sakshi Jain
Updated on 22-Aug-2023 18:58:00

157 Views

In the given problem statement we are asked to sort an array of numbers into some sets where the array is the input source provided by the user going from brute force method to optimized solution . What is an array in JavaScript ? If you are familiar with any other programming language like C, C++, or Java, you must have heard the term 'array.' In programming, an array is a collection of similar data elements under one roof. Now, an important question arises: if arrays are generally the same in all languages, then ... Read More

Advertisements