AmitDiwan has Published 10744 Articles

Finding reflection of a point relative to another point in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 07:41:36

370 Views

Point Of Symmetry"Point reflection" or "point symmetry" is a basic concept in geometry where a given point, P, at a given position relative to a midpoint, Q has a corresponding point, P1, which is the same distance from Q but in the opposite direction.ProblemWe are required to write a JavaScript ... Read More

Performing power operations on an array of numbers in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 07:39:46

411 Views

ProblemWe are required to write a JavaScript function that takes in an array of integers, arr, of even length.Suppose a number num where −num = (arr[0] * arr[0] + arr[1] * arr[1]) * (arr[2] * arr[2] + arr[3] * arr[3]) * … * (arr[n-2] * arr[n-2] + arr[n-1] * arr[n-1])Where ... Read More

Searching for target string in a strangely sorted array in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 07:36:53

153 Views

ProblemWe are required to write a JavaScript function that takes in a word target and an array of sorted(by length(increasing), number of uppercase letters(decreasing), natural order) unique words which always contains the target.The task of our function is to find the index(0 based) of the target in the array of ... Read More

Number difference after interchanging their first digits in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 07:35:17

81 Views

ProblemWe are required to write a JavaScript function that takes in an array of exactly two numbers. Our function should return the absolute difference between the numbers after interchanging their first digits.For instance, for the array [105, 413], The difference will be: |405 - 113| = 292ExampleFollowing is the code ... Read More

Interchanging first letters of words in a string in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 07:31:43

318 Views

ProblemWe are required to write a JavaScript function that takes in a string that contains exactly two words.Our function should construct and return a new string in which the first letter of the words are interchanged with each other.ExampleFollowing is the code − Live Democonst str = 'hello world'; const interchangeChars ... Read More

Finding the immediate bigger number formed with the same digits in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 07:30:18

309 Views

ProblemWe are required to write a JavaScript function that takes in a number n. Our function should rearrange the digits of the numbers such that we form the smallest number using the same digits but just bigger than the input number.For instance, if the input number is 112. Then the ... Read More

Removing the second number of the pair that add up to a target in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 07:27:15

131 Views

ProblemWe are required to write a JavaScript function that takes in an array of numbers and a target sum.Our function should remove the second number of all such consecutive number pairs from the array that add up to the target number.ExampleFollowing is the code − Live Democonst arr = [1, 2, ... Read More

Number of carries required while adding two numbers in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 07:14:05

345 Views

ProblemWe are required to write a JavaScript function that takes in two numbers.Our function should count the number of carries we are required to take while adding those numbers as if we were adding them on paper.Like in the following image while adding 179 and 284, we had used carries ... Read More

Finding smallest sum after making transformations in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 07:09:30

161 Views

ProblemWe are required to write a JavaScript function that takes in an array of positive integers. We can transform its elements by running the following operation on them as many times as required −if arr[i] > arr[j] then arr[i] = arr[i] - arr[j]When no more transformations are possible, our function ... Read More

Switching positions of selected characters in a string in JavaScript

AmitDiwan

AmitDiwan

Updated on 19-Apr-2021 07:07:01

362 Views

ProblemWe are required to write a JavaScript function that takes in a string that contains only the letter ‘k’, ‘l’ and ‘m’.The task of our function is to switch the positions of k with that of l leaving all the instances of m at their positions.ExampleFollowing is the code − Live ... Read More

Advertisements