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...
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...
Problem Given an integer array, increment its numeric value by one. For example, increment([2, 7, 3]) returns [2, 7, 4] Solution
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...
— 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...
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...
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...
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 :...
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...
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’,...
Input : [ 1, 2, 3 ] Output : [ ‘ ‘, 1, 2, 12, 3, 13, 23, 123 ] Logic : There are 2^n possible combinations for the array of...