Author Archives: Zrzahid

Permuting Lists of Lists – Print all possible words from phone digits

Given a list of arraylists containing elements, write a function that prints out the permutations of of the elements such that, each of the permutation set contains only 1 element from each arraylist and there are no duplicates in the list of permutation sets. For example: consider the following lists L1= {a1,b1,c1,d1} L2= {a2,b2,c2} L3= […]

Permutation and Combination

Permutation Permutation means arranging all the members of a set into some sequence or order, or if the set is already ordered, rearranging (reordering) its elements, a process called permuting. These differ from combinations, which are selections of some members of a set where order is disregarded. For example, written as tuples, there are six […]

Next even permutation of a number

Given a number N. Find the smallest even number greater than N such that the digits are a permutation of the number N. A trivial solution to start with would be to generate all the permutations of digits of the given number and then sort all the permutations. The first even permutation in the sorted […]

Multiply Two Big Integers

Given two big integers represented as strings, Multiplication them and return the production as string. For example, given a=2343324 and b=232232 then retiurn c = a*b = 23433242334323342 * 23223233232434324 = 544195652122144709711313995190808 We can see that the problem is trivial if we had given two small integers. But as the numbers can be really big […]

Moving Average of Last N numbers in a Stream

Design a class to calculate moving average of last N numbers in a stream of real numbers For example, if N=3 and the stream S=[2,3,4,1,2,-3,0,…] then moving averages at each each streamed number are = [2.0, 2.5, 3.0, 2.66, 2.33, 0, -0.33,…]. We need to design in a way that when a new element ins […]