Given a set S of digits [0-9] and a number n. Find the smallest integer larger than n (ceiling) using only digits from the given set S. You can use a value as many times you want.
Daily Archives: January 26, 2016
Vertical and Zigzag Traversal of Binary Tree
Given a binary tree. Print the nodes in vertical and zigzag manner.
For example, we have binary tree below:
1 / \ 2 3 / \ / \ 4 5 6 7
vertical traversal will output:
4
2
1 5 6
3
7
Find k such that kth row is all zero and kth col is all one in a matrix
Given a Boolean Matrix, find k such that all elements in k’th row are 0 and k’th column are 1. Do it in O(n) time
Given a binary matrix mat[n][n], find k such that all elements in k’th row are 0 and all elements in k’th column are 1. The value of mat[k][k] can be anything (either 0 or 1). If no such k exists, return -1.
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
Power Set or Super Set of a Set
Given a set of characters. Find the power set or super set of the set.
For example, S={a,b,c}, then powerSet = {{}, {a}, {b}, {c}, {a,b}, {b,c}, {a,c}, {a,b,c}}.