## Calculate tax on income as per given tax brackets.

Given a list of tax brackets (different tax on different incomes). Write a program to calculate the tax on given income.  Tax bracket is a pair consisting of amount and percentage tax on that amount. If amount is null means, it’s a highest bracket and percentage tax is mentioned will be applied to all the … Read more Calculate tax on income as per given tax brackets.

## Valid Pickup and Delivery options

Given N orders, each order consists of pickup and delivery services, means delivery of a particular service will after the pick up of the same service so the sequence pickup/delivery such that delivery(i) is after pickup(i). Write a program to count all valid pickup/delivery possible sequences Since the answer may be too large, return it … Read more Valid Pickup and Delivery options

## The largest number can be formed from the given number

Given a number write an algorithm to construct the largest number possible by using the digits of given number. Given number could be a negative number as well.  Example: Given Input: 34277765 Output: 77765432 Given Input: -342765 Output: -234567 Given Input: 0 Output: 0 Given Input: 2034 Output: 4320 Approach: Sorting Check if the given … Read more The largest number can be formed from the given number

## Construct the Largest number from the given digits

Given a set of digits, write an algorithm to construct the largest number possible by appending the given digits. Example: Given Digits: [9, 1, 9, 2, 8, 4, 2] largest number: 9984221 Given Digits: [1, 2, 5, 6, 7] largest number: 76521 Approach: Sorting Sort the given array in descending order. Initialize result = 0. … Read more Construct the Largest number from the given digits

## Numbers with prime set bits in a given range using Sieve of Eratosthenes Algorithm

Objective: Given a range, find all the numbers in the range which has prime set bits using Sieve of Eratosthenes Algorithm. Earlier we had seen a similar problem -Numbers with prime set bits in a given range solved in the naive approach. in this algorithm, we will improve the time complexity using the Sieve of … Read more Numbers with prime set bits in a given range using Sieve of Eratosthenes Algorithm

## Find all the Armstrong numbers in the given range

Objective: Given a range of integers, wrote a program to find all the Armstrong numbers in that range. What is Armstrong number: Determine the number of digits in the number. Call that n. Then take every digit in the number and raise it to the n power. Add all those together, and if your answer … Read more Find all the Armstrong numbers in the given range

## Collatz Conjecture – Maximum Steps takes to transform (1, N) to 1.

Objective: Given a number N, write an algorithm to find the maximum number of steps it takes to transform (1, N) to 1 using Collatz Conjecture.  The Collatz conjecture is a conjecture in mathematics which states that no matter what value of Positive Number N, If the below sequence is followed then the sequence will … Read more Collatz Conjecture – Maximum Steps takes to transform (1, N) to 1.

## Find all unique combinations of exact K numbers (from 1 to 9 ) with sum to N

Objective: Given two integers N and K. Write an algorithm to find all the combinations of k numbers which sum to N.  Conditions:  All K numbers must be between 1 and 9 and unique. All numbers in K are positive. Example: N= 5 K=2 Output: [1, 4] [2, 3] N =12 K=3 Output: [1, 2, … Read more Find all unique combinations of exact K numbers (from 1 to 9 ) with sum to N

## Evaluation of Prefix Expressions (Polish Notation) | Set 1

Prefix notation is a notation for writing arithmetic expressions in which the operands appear after their operators. There are no precedence rules to learn. Let’s assume the below Operands are real numbers in real digits. (Later we will Enhance the solution for any number) Permitted operators: +,-, *, /, ^(exponentiation) Blanks are NOT permitted in … Read more Evaluation of Prefix Expressions (Polish Notation) | Set 1

## Evaluation of Postfix Expressions (Polish Postfix notation) | Set 2

Earlier we had discussed how to evaluate postfix expressions where operands are of single-digit. In this article, we will discuss how to evaluate postfix expressions for any number ( not necessarily single digit.) Postfix notation is a notation for writing arithmetic expressions in which the operands appear before their operators. Let’s assume the below Operands … Read more Evaluation of Postfix Expressions (Polish Postfix notation) | Set 2

## Evaluation of Postfix Expressions (Polish Postfix notation) | Set 1

Postfix notation is a notation for writing arithmetic expressions in which the operands appear before their operators. There are no precedence rules to learn, and parentheses are never needed. Because of this simplicity. Let’s assume the below Operands are real numbers in single digits. (Read: Evaluation of Postfix Expressions for any Number ) Permitted operators: … Read more Evaluation of Postfix Expressions (Polish Postfix notation) | Set 1