Difference Between SATA and PATA

AmitDiwan
Updated on 24-Apr-2021 07:34:43

862 Views

In this post, we will understand the difference between SATA and PATA −PATAIt stands for Parallel Advanced Technology Attachment.It is a 40 pin connector.It is expensive.The speed of data transfer is low.It consumes more power.The size of the cable is big.It doesn’t come with hot swapping feature.External hard drives can’t be used with PATA.SATAIt stands for Serial Advanced Technology Attachment.It is a 7 pin connector.It is cheap.The speed of data transfer is high.It consumes less power.The size of the cable is small.It comes with the hot swapping feature.External hard drives can be used with SATA.Read More

Difference Between DLP and LCD Projector

AmitDiwan
Updated on 24-Apr-2021 07:21:55

323 Views

In this post, we will understand the difference between DLP and LCD projector −DLP Projector (Digital Light Processing)It is a type of projector that uses a digital micro mirror device.One of the chip has a reflective surface that contains thousands of tiny mirrors that are coordinated with a light source.This helps reflect the digital imagery on to any surface.It provides smooth video.The pixels are less visible.It is more film-like, as on HDTV.It shows the rainbow effect.The intensity of black is amazing.It is portable since it is small and light in weight.The light source could be a standard lamp or an ... Read More

Difference Between NC and CNC

AmitDiwan
Updated on 24-Apr-2021 07:15:59

225 Views

In this post, we will understand the difference between NC and CNC −NC (Numerical Control)It stands for Numerical Control.The input mechanism is punched tapes and punched cards.The modification in the machine programs can be done by changing the information on punched cards.The operational parameters can’t be changed.There is no memory to store instructions in them.It is less expensive.It requires very less maintenance.It is moderately accurate.The operators using this need to be highly skilled.It is not very flexible.It consumes more time.CNC (Computer Numerical Control)It stands for Computer Numerical Control.The input mechanism is that the program is fed data with the help ... Read More

Check if Change Can Be Provided in JavaScript

AmitDiwan
Updated on 23-Apr-2021 11:16:52

127 Views

ProblemWe are required to write a JavaScript function that takes in an array of numbers, arr, as the first and the only argument.Let us consider the following situation:A shopkeeper sells a single commodity which costs exactly ₹5. Some customers are standing in a queue and will purchase exactly one unit of this commodity each. The customers can provide the shopkeeper with a note of ₹5, ₹10 or ₹20. Considering that the shopkeeper has no money in the beginning and the array represents the notes given by the customers standing in the queue.Our function should determine whether or not the shopkeeper ... Read More

Maximize First Array Over Second in JavaScript

AmitDiwan
Updated on 23-Apr-2021 11:14:06

184 Views

ProblemWe are required to write a JavaScript function that takes in two arrays of numbers, arr1 and arr2, of the same length.Our function should shuffle the elements of the first array, arr1, such that its maximum number of elements are greater than corresponding elements of the array arr2. The function should then return the shuffled array.For example, if the input to the function isInputconst arr1 = [3, 5, 12, 19]; const arr2 = [2, 9, 3, 12];Outputconst output = [3, 12, 5, 19];Output ExplanationBefore shuffling arr1, it had 3 corresponding elements greater than that of arr2, but in the shuffled ... Read More

Finding Fibonacci Sequence in an Array Using JavaScript

AmitDiwan
Updated on 23-Apr-2021 10:05:48

598 Views

Fibonacci Sequence:A sequence X_1, X_2, ..., X_n is fibonacci if:n >= 3X_i + X_{i+1} = X_{i+2} for all i + 2 {    const map = arr.reduce((acc, num, index) => {       acc[num] = index       return acc    }, {})    const memo = arr.map(() => arr.map(() => 0))    let max = 0    for(let i = 0; i < arr.length; i++) {       for(let j = i + 1; j < arr.length; j++) {          const a = arr[i]          const b = arr[j]          const index = map[b - a]          if(index < i) {             memo[i][j] = memo[index][i] + 1          }          max = Math.max(max, memo[i][j])       }    }    return max > 0 ? max + 2 : 0 }; console.log(longestFibonacci(arr));Output5

Finding Middlemost Node of a Linked List in JavaScript

AmitDiwan
Updated on 23-Apr-2021 09:44:07

141 Views

ProblemWe are required to write a JavaScript function that takes in the head of a linked list as the first and the only argument.Our function should return the value stored in the middlemost node of the list. And if there are two middlemost nodes, we should return the second one of them.For example, if the list is like this:Input[4, 6, 8, 9, 1]Outputconst output = 8;Following is the code:Exampleclass Node {    constructor(data) {       this.data = data;       this.next = null;    }; }; class LinkedList {    constructor() {       this.head = ... Read More

Balancing Two Arrays in JavaScript

AmitDiwan
Updated on 23-Apr-2021 09:41:06

397 Views

ProblemWe are required to write a JavaScript function that takes in two arrays of numbers, arr1 and arr2, as the first and the second argument.The sum of elements in arr1 and arr2 are different. Our function should pick one element from the first array and push it in the second array and pick one element from the second array and push it in the first array such that the sum of the elements of both the arrays become equal. We should return an array of these two elements.For example, if the input to the function isInputconst arr1 = [1, 2, ... Read More

Maximum Subarray Sum in Circular Array Using JavaScript

AmitDiwan
Updated on 23-Apr-2021 09:11:28

208 Views

ProblemWe are required to write a JavaScript function that takes in an array of integers, arr, as the first and the only argument.We can consider this array arr to be a circular array, which means the last element of the array will be followed by the first. Our function should find and return the maximum possible sum of a non-empty subarray of arr.For example, if the input to the function isInputconst arr = [2, -2, 3, -1];Outputconst output = 4;Output ExplanationBecause the desired subarray is [3, -1, 2]Example Live Democonst arr = [2, -2, 3, -1]; const maxSubarraySumCircular = (arr = ... Read More

Placing Integers at Correct Index in JavaScript

AmitDiwan
Updated on 23-Apr-2021 07:43:05

132 Views

ProblemWe are required to write a JavaScript function that takes in a string, str, which consists of only ‘[‘ or ‘]’. Our function is supposed to add the minimum number of square brackets ( '[' or ']', and in any positions ) so that the resulting bracket combination string is valid. And lastly, we should return the smallest number of brackets added.For example, if the input to the function isInputconst str = '[]]';Outputconst output = 1;Output ExplanationBecause, if we add ‘[‘ to the starting, the string will be balanced.Exampleconst findAdditions = (str = '') => {    let left = 0 ... Read More

Advertisements