Tensorflow is a machine learning framework that is provided by Google. It is an open-source framework used in conjunction with Python to implement algorithms, deep learning applications, and much more. It is used in research and for production purposes.It has optimization techniques that help in performing complicated mathematical operations quickly.This is because it uses NumPy and multi-dimensional arrays. These multi-dimensional arrays are also known as ‘tensors’. The framework supports working with deep neural networks. It is highly scalable and comes with many popular datasets. It uses GPU computation and automates the management of resources. It comes with multitude of machine ... Read More
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
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
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
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
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
We are required to write a JavaScript function that takes in an array of arrays of numbers as the first argument and a number as the second argument. The subarrays contain numbers sorted in an increasing order and no element of a preceding subarray is greater than any element of the succeeding subarray.The function should use the binary search algorithm to search for the element provided as the second argument in the sorted array of arrays.If the element exists the function should return true, false otherwise.For example −If the input array is −const arr = [ [2, 6, 9, ... Read More
We are required to write a JavaScript function that takes in array of integers as the first and the only argument.Our function should find and return that smallest positive integer which is not present in the array.For example −If the input array is −const arr = [4, 2, -1, 0, 3, 9, 1, -5];Then the output should be −const output = 5;because 1, 2, 3, 4 are already present in the array and 5 is the smallest positive integer absent from the array.ExampleFollowing is the code −const arr = [4, 2, -1, 0, 3, 9, 1, -5]; const findSmallestMissing = ... Read More
We are required to write a JavaScript function that takes in an array of numbers as the first argument and a number as the second argument. The function should prepare and return an array of all such triplets (consecutive or nonconsecutive), that add up to the number specified by the second argument.For example −If the input array and the number are −const arr = [4, 2, 0, 1, 2, 6, 8, 3, 2, 5]; const num = 8;Then the output array should be −const output = [ [ 2, 2, 4 ], [ 1, 3, 4 ], [ 0, 2, ... Read More
We are required to write a JavaScript function that takes in two numbers, let’s say m and n as arguments.n will always be smaller than or equal to the number of digits present in m. The function should calculate and return the sum of first n digits of m.For example −If the input numbers are −const m = 5465767; const n = 4;Then the output should be −const output = 20;because 5 + 4 + 6 + 5 = 20ExampleFollowing is the code −const m = 5465767; const n = 4; const digitSumUpto = (m, n) => { if(n ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP