
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10483 Articles for Web Development

781 Views
We are required to write a JavaScript function that takes in two strings, str1 and str2 that represents two numbers.Without converting the whole strings to respective numbers, our function should calculate the sum of those two string numbers and return the result as a string.For example −If the two strings are −const str1 = '234'; const str2 = '129';Then the output should be 363.−ExampleFollowing is the code −const str1 = '234'; const str2 = '129'; const addStringNumbers = (str1, str2) => { let ind1 = str1.length - 1, ind2 = str2.length - 1, res = "", ... Read More

476 Views
We are required to write a JavaScript function that takes in a string as the first and the only argument.The function should find and return the index of first character it encounters in the string which appears only once in the string.If the string does not contain any unique character, the function should return -1.For example −If the input string is −const str = 'hellohe';Then the output should be −const output = 4;ExampleFollowing is the code −const str = 'hellohe'; const firstUnique = (str = '') => { let obj = {}; for(let i = 0; i < ... Read More

193 Views
We have an array of integers which is sorted in the increasing order. We are required to write a JavaScript function that takes in one such array as the first argument and a target sum number as the second argument.The function should find and return two such numbers from the array that when added gives the target sum. The condition for solving this problem is that we have to do this in linear time and using constant space.ExampleFollowing is the code −const arr = [4, 6, 8, 9, 11, 12, 18, 21]; const num = 27; const findElements = (arr ... Read More

480 Views
A sentence is just a string which contains strings (called words) joined by whitespaces. We are required to write a JavaScript function that takes in one such sentence string and count the number of characters in the second to last word of the string. If the string contains no more than 2 words, our function should return 0.For example −If the input string is −const str = 'this is an example string';Then the output should be −const output = 7;because the number of characters in example is 7.ExampleFollowing is the code −const str = 'this is an example string'; const ... Read More

473 Views
We are required to write a JavaScript function that takes in an array of numbers as the first and the only argument.The function should find and return one such number from the array which is greater than both, the number on its immediate right and the number on its immediate left. If there exists more than one such element in the array, our function should return any one of them.For example −If the input array is −const arr = [3, 6, 7, 9, 8, 2, 5];Then the output should be −const output = 9;Since the question demands finding the peak ... Read More

144 Views
We are required to write a JavaScript function that takes in an array of integers as the only argument.The array is first sorted and then rotated by any arbitrary number of elements. Our function should find the smallest element in the array and return that element.The only condition is that we have to do this in less than linear time complexity, maybe using a somewhat tweaked version of the binary search algorithm.For example −If the input array is −const arr = [6, 8, 12, 25, 2, 4, 5];Then the output should be 2.ExampleFollowing is the code −const arr = [6, ... Read More

130 Views
We are required to write a JavaScript function that takes in an array of integers (positive and negative) as the first and the only argument. The function should find out and return the product of subarray where its maximum.For example −If the input array is −const arr = [4, -5, 2, -3, 1, -4, 0, -3];Then the output should be −const output = 120because the subarray with maximum product is [4, -5, 2, -3]ExampleFollowing is the code −const arr = [4, -5, 2, -3, 1, -4, 0, -3]; const maxProduct = (arr = []) => { if (arr.length === 0){ return 0; }; let max = arr[0], min = arr[0], greatest = arr[0]; for (let i = 1; i

514 Views
We are required to write a JavaScript function that takes in an array of integers as the first and the only argument.The function should find and return the length of the longest consecutive increasing sequence that exists in the array (contiguous or non-contiguous).For example −If the input array is −const arr = [4, 6, 9, 1, 2, 8, 5, 3, -1];Then the output should be 6 because the longest consecutive increasing sequence is 1, 2, 3, 4, 5, 6.ExampleFollowing is the code −const arr = [4, 6, 9, 1, 2, 8, 5, 3, -1]; const consecutiveSequence = (arr = []) ... Read More

2K+ Views
We are required to write a JavaScript function that takes in an array of literals as the first and the only argument.The function should construct and return an array of all possible subarrays that can be formed from the original array.For example −If the input array is −const arr = [1, 2, 3];Then the output should be −const output = [ [2], [1], [3], [1, 2, 3], [2, 3], [1, 2], [1, 3], [] ];The order of subarrays is not that important.ExampleFollowing is the code −const arr = [1, 2, 3]; const ... Read More

483 Views
We are required to write a JavaScript function that takes in an array of arrays of characters as the first argument and a string as the second argument.The function should find out whether there exist characters in the matrix, non-repeating combination of which yields the string provided to the function as the second argument.If there exists such a combination, our function should return true, false otherwise.For example −If the input array and the string are −const arr = [ ['s', 'd', 'k', 'e'], ['j', 'm', 'o', 'w'], ['y', 'n', 'l'] ]; const str = 'don';Then the output ... Read More