Tag Archives: hard

Check for Same BSTs from Arrays: GeeksforGeeks

Problem link: http://www.geeksforgeeks.org/check-for-identical-bsts-without-building-the-trees/

Problem Statement:
Given two arrays which represent a sequence of keys. Imagine we make a Binary Search Tree (BST) from each array. We need to tell whether two BSTs will be identical or not without actually constructing the tree.
For example, the input arrays are {2, 4, 3, 1} and {2, 1, 4, 3} will construct the same tree
Continue reading


Utopian Identification Number: Hackerrank

Problem link: https://www.hackerrank.com/challenges/utopian-identification-number

Problem Statement:
A new identification number is given for every Citizen of the Country Utopia and it has the following format.

1. The string must begin with between 0 and 3 (inclusive) lowercase letters.
2. Immediately following the letters, there must be a sequence of digits. The length of this segment must be between 2 and 8, both inclusive.
3. Immediately following the numbers, there must be at least 3 uppercase letters.

Your task is to find out if a given identification number is valid or not.
Continue reading

2’s complement : Hackerrank

Problem link: https://www.hackerrank.com/challenges/2s-complement

Problem Statement:
One of the basics of Computer Science is knowing how numbers are represented in 2’s complement. Imagine that you write down all numbers between A and B inclusive in 2’s complement representation using 32 bits. How many 1’s will you write down in all ?
Continue reading

FewestFactors : TopCoder Problem 5886

[The problem appeared in TopCoder SRM 272 (Div-1, Level-1) and SRM 271 (Div-2, Level-2)]
Problem link: http://community.topcoder.com/stat?c=problem_statement&pm=5886

Problem Statement:
You will be given some decimal digits in a int[] digits. Build an integer with the minimum possible number of factors, using each of the digits exactly once (be sure to count all factors, not only the prime factors). If more than one number has the same (minimum) number of factors, return the smallest one among them.
Continue reading