# Convert number to word

Write a program to convert number to word For example:467Four hundred sixty seven 2321Two thousand three hundred twenty one Solution: Continue reading Convert number to word

# Binary Triangle

Generate a Binary Triangle from the given number. Binary Triangle is a Triangle formed with 1’s and 0’s. The number of rows in the binary triangle is user input. example: 5 Rows Binary Triangle Solution: Continue reading Binary Triangle

# Sum of all sub arrays in O(n) Time

Given an array write C# program to find the sum of all the possible sub-arrays. For.e.g. int [] a = {4, 2, 1}; Output: Possible subarrays – {4}, {2}, {1}, {4, 2}, {2, 1}, {4, 2, 1} So, sum = 4+ 2+ 1 + 6 + 3 + 7 = 23 Solution Brute force approach Problem with below program is iterating over all pairs of … Continue reading Sum of all sub arrays in O(n) Time

# Frog Jump Problem

Problem A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone.  Given an array of stones (non-negative integers) where each element in the array represents the maximum number of positions one can move forward from that element. Write a program to Find the minimum number of jumps required to cross … Continue reading Frog Jump Problem

# Find all sub-array from array

Question: Find all possible subarray from given array Given an array of positive integers,  Write an C# Program to find all sub arrays from an array. Answer: Subarray of an array a is a[i..j] where 0 <= i <= j < n where n is length of array. Continue reading Find all sub-array from array

# Primitive Root

Question: Given a prime number n and mod  k number find out whether provided prime number n is having a primitive root mod k Answer A primitive root mod n is an integer g such that every integer relatively prime to n is congruent to a power of g mod n. That is, the integer g is a primitive root (mod n) if for every number a relatively prime to n there is an integer z such that  a = (gz (mod n)) for example: 2 is a primitive root mod 5, because for … Continue reading Primitive Root

# Find Pair of sum in Array.

Question Given an array of unsorted array and a number, determines all pair in array in array whose sum is equivalent to the given number For example: from provided Array “arr” find all Pair who sum is 4 Answer: Logic: Get the difference between array elements and given sum number Find the difference in reaming array to get the pairs Continue reading Find Pair of sum in Array.

# Convert Decimal to Binary (base -2)

Question: Write a C# program to convert any decimal number (base-10 (0 to 9)) into binary number (base-2 (0 or 1))? Answer: Decimal Number – Decimal number is a base 10 number because it ranges from 0 to 9, there are total 10 digits between 0 to 9. Any combination of digits is decimal number such as 223, 585, 192, 0, 7 etc.   Binary … Continue reading Convert Decimal to Binary (base -2)