AmitDiwan has Published 8358 Articles
AmitDiwan
176 Views
We are required to write a JavaScript function that takes in an array of numbers, arr, as the first argument and a single number, num, as the second argument.The function should then find two such numbers whose sum is greatest in the array but just less than the number num. ... Read More
AmitDiwan
504 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 construct and return a new array that contains all such elements from the original array whose successor and predecessor are both present in the array. If ... Read More
AmitDiwan
224 Views
Majority Element:A majority element in an array arr of length l is an element that appears more than l/2 times and hence there is at most one such element.We need to write a JavaScript function, say isMajority() that takes an array arr which is always sorted in the increasing order ... Read More
AmitDiwan
380 Views
We will be given an array of arrays, each subarray consists of exactly two elements indicating the start and end time of a meeting.The task of our function is to find the maximum number of meetings one person can take avoiding the conflict of time. The function should finally return ... Read More
AmitDiwan
2K+ Views
Suppose we have a string str containing lowercase English letters, and an array of arrays arr, where arr[i] = [direction, amount] −direction can be 0 (for left shift) or 1 (for right shift).amount is the amount by which string s is to be shifted.A left shift by 1 means remove ... Read More
AmitDiwan
456 Views
Arithmetic Progression:An arithmetic progression (AP) or arithmetic sequence is a sequence of numbers such that the difference between the consecutive terms is constant.For instance, the sequence 5, 7, 9, 11, 13...Suppose we have an array that represents elements of arithmetic progression in order. But somehow one of the numbers from ... Read More
AmitDiwan
294 Views
Confusing Numbers:A number in an array is confusing if it becomes another number which is also present in the array after we rotate the number by 180 degrees vertically and horizontally. For instance, if we rotate 6 by 180 degrees vertically and horizontally it becomes 9 and vice-versa.We have to ... Read More
AmitDiwan
255 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 first pick the smallest number from the array and then calculate the sum of all the digits of the number.If the digit sum of that ... Read More
AmitDiwan
291 Views
Word Square:A word square consists of a set of words written out in a square grid, such that the same words can be read both horizontally and vertically.For instance, once valid word square is −H E A R T E M B E R A B U S E R ... Read More
AmitDiwan
460 Views
Suppose we are given an array of sorted characters letters containing only lowercase letters. And given a target letter target.We are required to write a JavaScript function that takes in the array as the first argument and the letter as the second. The function is supposed to find the smallest ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP