# Tagged: Array

## Loop over an array with the given timeout for each element

Problem You are given an array of objects each with its name and timeout value. Iterate over each element inside an array in the interval of the given timeout. Solution We have to set...

## increment an integer array by one

Problem Given an integer array, increment its numeric value by one. For example, increment([2, 7, 3]) returns [2, 7, 4] Solution

## Find target subtraction is possible in a given unsorted array of numbers

Problem statment Given an array of unsorted numbers and a target element. Find if any two elements subtract to the target element or not. You can loop through the array only once. Constraint: Time...

## Implement the function that determines whether you can or cannot seat a number of people in the row.

— Problem People are sitting in a theater row and you’re an usher. Given a row of seats that either occupied (1) or unoccupied (0) and the condition that new people being seated...

## Given an array of numbers, return array of products of all other numbers

Problem Given an array of n integers, return an array of same size such that prod[i] is equal to the product of all the elements of arr[] except arr[i].   Restrictions  – Not allowed to...

## Implement zip in javascript

Reducing an array to a single value When we need to combine two arrays by progressively taking an item from each and combining the pair. If you visualize a zipper, where each side is...

## find pivot in an sorted rotated array

Problem : Given a sorted and rotated array find the index of a pivot element in an array. Input : An array Output : An index Algorithm : Binary search tree Time complexity :...

## Dedupe an array in javascript

Input : An array Output : An array Logic : Iterate over the input array called data Add the element to the output array called result if the element does not exist in the...

## Generate all permutations of a given array using backtracking

A permutation is a rearrangement of the elements in a list. A string/array of length n has n! permutation. Input: An array // [‘A’, ‘B’, ‘C’] Output: [‘A’, ‘B’, ‘C’] [‘A’, ‘C’, ‘B’], [‘B’,...

## Generate all combinations of an array

Input : [ 1, 2, 3 ]   Output : [  ‘ ‘,  1,  2,  12,  3,  13,  23,  123  ]   Logic : There are 2^n possible combinations for the array of...