- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 10710 Articles for Web Development
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
148 Views
ProblemWe are required to write a JavaScript function that takes in an array, arr, as the first and the only argument.The array arr consists of string equations of one of the two following kinds −‘X ===Y’X!==Y’Here, X and Y can be any variables.Our function is supposed to check whether for all the equations in the array, we can assign some number so that all the equations in the array yield true.For example, if the input to the function is −const arr = ['X===Y', 'Y!==Z', 'X===Z'];Then the output should be −const output = false;Output Explanation:No matter what value we choose for ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
92 Views
ProblemWe are required to write a JavaScript function that takes in two numbers, m and n, as the first and the second argument.Our function is supposed to count the number of minimum operations required to reach n from m, using only these two operations −Double − Multiply the number on the display by 2, or;Decrement − Subtract 1 from the number on the display.For example, if the input to the function is −const m = 5; const n = 8;Then the output should be −const output = 8;Output Explanation:Because the operations are −5 → 4 → 8ExampleThe code for this ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
103 Views
ProblemWe are required to write a JavaScript function that takes in an array of literals, arr, as the first argument. The second argument to our function will be a number, num. Our function should count and return the number of subarrays of the array that contains exactly num distinct elements.For example, if the input to the function is −const arr = [12, 15, 12, 15, 18]; const num = 2;Then the output should be −const output = 7;Output ExplanationSubarrays formed with exactly 2 different elements −[12, 15], [15, 12], [12, 15], [15, 18], [12, 15, 12], [15, 12, 15], [12, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
79 Views
ProblemWe are required to write a JavaScript function that takes in a 2-D array of numbers, arr, as the only argument.The numbers in the array can be −the value 0 which represents an empty cell;the value 1 which represents a fresh tomato;the value 2 which represents a rotten tomato.Every minute, any fresh tomato that is adjacent (4-directionally) to a rotten tomato becomes rotten.Our function is supposed to return the minimum number of minutes that must elapse until no cell has a fresh tomato. If this is impossible, we should return -1 instead.For example, if the input to the function is ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
70 Views
ProblemWe are required to write a JavaScript function that takes in an array of strings, arr, as the first and the only argument.Our function is supposed to return an array of all characters that show up in all strings within the array arr (including duplicates).For example, if a character occurs 2 times in all strings but not 3 times, we need to include that character 2 times in the final answer.For example, if the input to the function is −const arr = ['door', 'floor', 'crook'];Then the output should be −const output = ['r', 'o', 'o'];ExampleThe code for this will be ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
111 Views
ProblemWe are required to write a JavaScript function that takes in a binary arr (array that contains only 0 or 1), arr, as the first argument, and a number, num, as the second argument.We can change at most num 0s present in the array to 1s, and our function should return the length of the longest (contiguous) subarray that contains only 1s after making these changes.For example, if the input to the function is −const arr = [1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0]; const num = 2;Then the output should be −const output = 6;Output ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
71 Views
ProblemWe are required to write a JavaScript function that takes in an array of integers as the first and the only argument. Our function should return true if and only if we can partition the array into three non-empty parts with equal sums, false otherwise.For example, if the input to the function is −const arr = [3, 3, 6, 5, -2, 2, 5, 1, -9, 4];Then the output should be −const output = true;Output ExplanationBecause, 3 + 3 = 6 = 5 - 2 + 2 + 5 + 1 - 9 + 4ExampleThe code for this will be − Live ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
76 Views
ProblemJavaScript function that takes in an array of Integers, arr, as the first and the only argument.Our function should pick an index pair (i, j) such that (arr[i] + arr[j]) + (i - j) is maximum amongst all index pairs in the array. Our function should then return the maximum value.For example, if the input to the function is −const arr = [8, 1, 5, 2, 6];Then the output should be −const output = 11;Output ExplanationBecause if we choose i = 0 and j = 2 then the value will be −(8 + 5) + (0 - 2) = 11Which ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
116 Views
ProblemWe are required to write a JavaScript function that takes in the head of the linked list as the first and the only argument.This linkedlist contains numerical data. Each node in the list may have a next larger value: for node_i, next_larger(node_i) is the node_j.val such that j > i, node_j.val > node_i.val, and j is the smallest possible choice. If such a j does not exist, the next larger value is 0.Our function should prepare and return an array in which the corresponding element is the next greater element for the element in the list.For example, if the list ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
ProblemJavaScript function that takes in a string, str, as the first and the only argument.A duplicate removal consists of choosing two adjacent and equal letters, and removing them.We repeatedly make duplicate removals on string str until we no longer can.And our function should finally return the final string after all such duplicate removals have been made.For example, if the input to the function is −const str = 'kllkmk';Then the output should be −const output = 'mk';Output Explanation:Firstly, we will remove ‘ll’ from the string to reduce it to ‘kkmk’, then after removing ‘kk’, we will return the new string.ExampleThe code ... Read More