
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
AmitDiwan has Published 10744 Articles

AmitDiwan
265 Views
We have to write a function that takes in a number and keeps adding its digit until the result is not a one-digit number, when we have a one-digit number, we return it.The code for this is pretty straightforward, we write a recursive function that keeps adding digit until the ... Read More

AmitDiwan
343 Views
We have to write a function that takes in an array and returns the index of the first nonconsecutive number from it. Like all the numbers will be in an arithmetic progression of common difference 1. But the number, which violates this rule, we have to return its index.If all ... Read More

AmitDiwan
161 Views
We have to write a function that creates an array with elements repeating from the string till the limit is reached. Suppose there is a string ‘aba’ and a limit 5 −string = "aba" and limit = 5 will give new array ["a", "b", "a", "a", "b"]Let’s write the code ... Read More

AmitDiwan
270 Views
Our job is to write a function that solves the two-sum problem in at most linear time.Two Sum ProblemGiven an array of integers, we have to find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers that add ... Read More

AmitDiwan
761 Views
Let’s say, we have to write a function, say translate() that accepts a string as the first argument and any number of words after that.The string will actually contain n $ signs like this −This $0 is more $1 just a $2. Then there will be 3 strings which will ... Read More

AmitDiwan
300 Views
We have to write a function that takes in an array and moves all the zeroes present in that array to the end of the array without using any extra space. We will use the Array.prototype.forEach() method here along with Array.prototype.splice() and Array.prototype.push().The code for the function will be −Exampleconst ... Read More

AmitDiwan
200 Views
We have to create a function that takes in any number of arguments (Number literals), adds them together, and returns the product of digits when the answer is only 1 digit long.For example −If the arguments are −16, 34, 42We have to first add them together −16+34+42 = 92And then ... Read More

AmitDiwan
378 Views
We have to write a recursive function fibonacci() that takes in a number n and returns an array with first n elements of fibonacci series. Therefore, let’s write the code for this function −Exampleconst fibonacci = (n, res = [], count = 1, last = 0) => { if(n){ ... Read More

AmitDiwan
718 Views
We have an array of string literals like this −const arr = ['Some', 'random', 'words', 'that', 'actually', 'form', 'a', 'sentence.'];We are required to write a function that returns the longest and the shortest word from this array. We will use Array.prototype.reduce() method to keep track of the longest and shortest ... Read More

AmitDiwan
507 Views
Let’s say, we have to write a function that takes in an array and returns another array in which the consecutive similar numbers are added up together.For example −const array = [1, 5, 5, 5, 8, 8, 9, 1, 4, 4, 2];The output should be −[1, 15, 16, 9, 1, ... Read More