0% found this document useful (0 votes)
20 views6 pages

Bank Comparison and Problem Solving Guide

The document presents five programming problems involving financial calculations, combinatorial counting, and allocation scenarios. Problem 1 requires comparing loan offers from two banks based on interest rates, while Problem 2 involves counting ways to climb stairs. Problems 3, 4, and 5 focus on generating numbers with specific digit sums, distributing job costs among employees, and allocating houses to homeless individuals based on height and house capacity, respectively.

Uploaded by

pnr.cse
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views6 pages

Bank Comparison and Problem Solving Guide

The document presents five programming problems involving financial calculations, combinatorial counting, and allocation scenarios. Problem 1 requires comparing loan offers from two banks based on interest rates, while Problem 2 involves counting ways to climb stairs. Problems 3, 4, and 5 focus on generating numbers with specific digit sums, distributing job costs among employees, and allocating houses to homeless individuals based on height and house capacity, respectively.

Uploaded by

pnr.cse
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Question 1: Bank Compare Problem

Problem Description :

Question – : There are two banks – Bank A and Bank B. Their interest rates vary.
You have received offers from both banks in terms of the annual rate of interest,
tenure, and variations of the rate of interest over the entire [Link] have to
choose the offer which costs you least interest and reject the other. Do the
computation and make a wise choice.

The loan repayment happens at a monthly frequency and Equated Monthly


Installment (EMI) is calculated using the formula given below :

EMI = loanAmount * monthlyInterestRate / ( 1 – 1 / (1 +


monthlyInterestRate)^(numberOfYears * 12))

Constraints:

 1 <= P <= 1000000


 1 <=T <= 50
 1<= N1 <= 30
 1<= N2 <= 30

Input Format:

 First line: P principal (Loan Amount)


 Second line: T Total Tenure (in years).
 Third Line: N1 is the number of slabs of interest rates for a given period by Bank A. First
slab starts from the first year and the second slab starts from the end of the first slab and
so on.
 Next N1 line will contain the interest rate and their period.
 After N1 lines we will receive N2 viz. the number of slabs offered by the second bank.
 Next N2 lines are the number of slabs of interest rates for a given period by Bank B. The
first slab starts from the first year and the second slab starts from the end of the first slab
and so on.
 The period and rate will be delimited by single white space.
Output Format: Your decision either Bank A or Bank B.

Explanation:

 Example 1
o Input
o 10000
o 20
o 3
o 5 9.5
o 10 9.6
o 5 8.5
o 3
o 10 6.9
o 5 8.5
o 5 7.9

 Output: Bank B

 Example 2
o Input
o 500000
o 26
o 3
o 13 9.5
o 3 6.9
o 10 5.6
o 3
o 14 8.5
o 6 7.4
o 6 9.6
 Output: Bank A

Question 2: Staircase Problem

Problem Description :

There are n stairs, a person standing at the bottom wants to reach the top. The
person can climb either 1 stair or 2 stairs at a time.

 Count the number of ways, the person can reach the top.

Question 3:
You have a positive integer m and a non-negative integer s. Your task is to find the
smallest and the largest of the numbers that have length m and sum of digits s. The
required numbers should be non-negative integers written in the decimal base
without leading zeroes.

Input

 The single line of the input contains a pair of integers m, s (1 ≤ m ≤ 100, 0 ≤ s ≤ 900) — the
length and the sum of the digits of the required numbers.

Output

 In the output print the pair of the required non-negative integer numbers — first the
minimum possible number, then — the maximum possible number. If no numbers
satisfying conditions required exist, print the pair of numbers “-1 -1” (without the quotes).

Examples

 Input 1
2 15
 Output 1
69 96

 Input 2
30
 Output 2
-1 -1

Question 4: HR issues

Problem statement -:

Shovon is an HR in a renowned company and he is assigning people to work. Now


he is assigning people work in a fashion where if he assigns some work a work of
cost 2, the next person will be strictly getting a job with cost equal or more than 2.
Given that Shovon’s company has infinite work and a number of employees, how
many distributions can be possible. The cost of jobs can go 0 to 9.

Function Description:

Complete the special_numbers function in the editor below. It has the following
parameter(s):
Parameters:

Name Type Description


N Integer The number of depts.
arr[ ] Integer array The number of employees in each dept..

Return: The function must return an INTEGER denoting the sum of answers for all
distinct distributions.

Constraints:

 1 <= n <= 100


 1 <= arr[i] <= 200

Sample Cases:

 Sample Input 1
2
4
1
 Sample Output 1
725
 Description
The ans if m = 1 is 10, which is all numbers from 0 to 9
The ans for m = 2 is 55
The answer for m = 3 is 220
The answer for m = 4 is 715
So fun(4) + fun(1) = 725

Question 5: Find the homeless

Problem Statement -: There are N Homeless people in the community and N


houses in the community. It will be given in the array (people) , height of the person
and in the array house capacity of the house is given.

Government decided to give homes for people on the basis of following conditions:

 Priority is given for the people from left to right of the array
 Each person is allotted to a house if and only if the capacity of house is greater than or
equal to persons height
 Nearby empty Houses are alloted to the person( starting from extreme left)
You need to find the number of homeless people who have not allotted any home if
the government follows the above [Link] that government will have an idea
for how many people they need to allot home for next time.

Constraints:

 1 <= N <= 10^3


 1 <= people[i] <= 10^5
 1 <= house[i] <= 10^5

Input Format for Custom Testing:

 The first line contains an integer, N, denoting the number of people and number of
houses.
 Each line i of the N subsequent lines (where 0 <= i <= N) contains an integer describing
peoplei.
 Each line i of the N subsequent lines (where 0 <= i <= N) contains an integer describing
housei.

Sample Test Cases

 Sample Input 1
3
4
2
7
3
5
10
 Sample Output 1
0
 Explanation
people=[4,2,7]
house=[3,5,10]
People[0] has more priority , from left to right order in houses 5 is the nearest one which
fits for people[0]
people[1]=2 will fit in 3 which is nearer from left
people[2]=7 will fit in remaining house of capacity of 10
So no homeless people left so return 0

 Sample Input 2
3
3
8
5
1
9
4
 Sample Output 2
2
 Explanation
people=[3,8,5]
house=[1,9,4]
people[0]=3 can fit in 9 which is nearest from left in array house
people[1]=8 cannot fit in any home which is left (i.e, 1 and 4)
people[2]=5 cannot fit in any home which is left (i.e, 1 and 4)
So return 2,which is number of homeless people

You might also like