AmitDiwan has Published 10740 Articles

Find the Length of the Longest possible palindrome string JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 05:54:14

441 Views

Given a string s which consists of lowercase or uppercase letters, we are required to return the length of the longest palindrome that can be built with those letters. Letters are case sensitive, for example, "Aa" is not considered a palindrome here.For example −If the input string is −const str ... Read More

Finding square root of a non-negative number without using Math.sqrt() JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 05:52:47

368 Views

We are required to write a JavaScript function that takes in a non-negative Integer and computes and returns its square root. We can floor off a floating-point number to an integer.For example: For the number 15, we need not to return the precise value, we can just return the nearest ... Read More

Reversing vowels in a string JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 05:51:39

407 Views

We are required to write a JavaScript function that takes a string as input and reverse only the vowels of a string.For example −If the input string is −const str = 'Hello';Then the output should be −const output = 'Holle';The code for this will be −const str = 'Hello'; const ... Read More

JavaScript group array - find the sets of numbers that can be traveled to using the edges defined

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 05:49:44

120 Views

Consider the following input and output arrays −const input = ["0:3", "1:3", "4:5", "5:6", "6:8"]; const output = [    [0, 1, 3],    [4, 5, 6, 8] ];Considering each number as a node in a graph, and each pairing x:y as an edge between nodes x and y, we ... Read More

JavaScript function that takes a multidimensional and a single array, and finds matches of the single array in the multi-d array

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 05:47:48

172 Views

We are required to write a JavaScript function that takes in an array of arrays of Numbers as the first argument and an array of Numbers as the second argument. The function should pick a subarray from each array of the first array, (subarray that contains item common to both ... Read More

How to find and return the longest repeating series of numbers in array with JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 05:45:29

617 Views

We are required to write a JavaScript function that takes in an array of Numbers that may contain some repeating elements. The function should return the length of the longest repeating number sequence from the array.For example −If the input array is −const arr = [2, 1, 1, 2, 3, ... Read More

Sorting Array based on another array JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 05:44:03

451 Views

Suppose, we have two arrays like these −const input = ['S-1', 'S-2', 'S-3', 'S-4', 'S-5', 'S-6', 'S-7', 'S-8']; const sortingArray = ["S-1", "S-5", "S-2", "S-6", "S-3", "S-7", "S-4", "S-8"];We are required to write a JavaScript function that takes in two such arrays as first and second argument respectively.The function should ... Read More

Convert JSON to another JSON format with recursion JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 05:42:20

2K+ Views

Suppose, we have the following JSON object −const obj = {    "context": {       "device": {          "localeCountryCode": "AX",          "datetime": "3047-09-29T07:09:52.498Z"       },       "currentLocation": {          "country": "KM",         ... Read More

Deep Search JSON Object JavaScript

AmitDiwan

AmitDiwan

Updated on 21-Nov-2020 05:38:35

6K+ Views

Suppose we have the following nested JSON object −const obj = {    id: 1,    title: 'hello world',    child: {       id: null,       title: 'foobar',       child: {          id: null,          title: 'i should ... Read More

Reduce array in JavaScript

AmitDiwan

AmitDiwan

Updated on 20-Nov-2020 13:52:56

225 Views

Suppose, we have an array of objects like this −const arr = [    {"time":"18:00:00"},    {"time":"10:00:00"},    {"time":"16:30:00"} ];We are required to write a JavaScript function that takes in one such array and does the following −Extract the times from the json code: so: 18:00:00, 10:00:00, 16:30:00Convert the times ... Read More

Advertisements