PPS Case Study
PPS Case Study
Input Format
A line consisting of a sequence of 9 (not necessarily distinct) single digits (any of 0-9) separated by
commas. The sequence will be non-decreasing
Output
The maximum possible time in a 24 hour clock (00:00:01 to 24:00:00) in a HH:MM:SS form that can
be formed by using some six of the nine given digits (in any order) precisely once each. If no
combination of any six digits will form a valid time, the output should be the word Impossible
Explanation
Example 1
Input
0,0,1,1,3,5,6,7,7
Output
17:57:36
The maximum valid time in a 24 hour clock that can be formed using some six of the 9 digits
precisely
once is 17:57:36
Example 2
Input
3,3,3,3,3,3,3,3,3
Output
Impossible
No set of six digits from the input may be used to form a valid time.
A Milkman serves milk in packaged bottles of varied sizes. The possible size of the bottles are
{1, 5, 7 and 10} litres. He wants to supply the desired quantity using as fewer bottles as possible
irrespective of the size. Your objective is to help him find the minimum number of bottles
required to supply the given demand for milk.
Input Format:
The first line contains the number of test cases N
Next N lines, each contains a positive integer Li which corresponds to the demand of milk.
Output Format:
For each input Li, print the minimum number of bottles required to fulfill the demand
Constraints:
1 <= N <= 1000 Li > 0 1 <= i<= N
Sample Input and Output:
2
17
65
27
Explanation:
Number of test cases is 2
For 17 = 10*1 + 7*1 = 2
For 65 = 10*6 + 5*1 = 7
Few more examples:
For 99 = 10*9 + 7*1 + 1*2 = 12
For 63 = 10*6 + 1*3 =9
3. Given an unsorted array ‘a’ of size N of non-negative integers, find a continuous sub-array which
adds to a given number sum. Input Format: The first line contains an integer, denoting the size of the
array. The second line contains integers denoting the elements of the array. The last line contains an
integer, denoting the sum.
Constraints 1<= n<=100
1<=arr<= 1000, where arr is the ith element of the array.
1<= n<=100000
Output Format:
The output line contains integers denoting the indexes.
TESTCASE 1:
Input:
7
[1, 4, 0, 0, 3, 10, 5]
sum = 7
Output:
Sum found between indexes 1 and 4
TESTCASE 2:
Input:
2
[1, 4]
sum = 0
Output:
No subarray found
Sample Input:
architect
tailor
referee
electrician
nurse
blacksmith
####
Sample Output:
architect
tailor
referee
electrician
nurse
People nowadays like doing thing through online for example shopping online, bill payment online,
study online and many more. In order to make people easier and save the time, Movie Ticket Booking
System was introduced. This system can save people time by no need to go to the cinema and buy the
ticket. This system require people to booking and buy movie ticket through online. People can choose
what type of movie they want to watch and what type of seat they want to choose.
This system also give permission to choose how many movie you like and what seat you want.
The total price will calculated at the end of the booking process.
totalprice=ticket+price;
After the seat has been chosen, program will display no of seat and also available seat that had left
seatAvlb=seats-people;
8. You have a certain number of 100 rupee notes, 10 rupee notes and 1 rupee notes with you.
There is an item you want to buy whose price is given to you.
Write a program to find if the item is affordable, that is the price of the item is less than or equal to the
current money you have.
Input
-----
Four non negative integers.
The first input is an integer representing the number of 100 rupee notes.
The second input is an integer representing the number of 10 rupee notes.
The third input is an integer representing the number of 1 rupee notes.
The fourth input is an integer representing the price of the item.
Output
------
You have to output 1 if the item is affordable.
You have to output 0 if the item is not affordable.
9. Bank Compare
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 tenure.
You 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 * monthly InterestRate / ( 1 – 1 / (1 + monthly InterestRate)^(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.
Sample Input 1:
10000
20
3
5 9.5
10 9.6
5 8.5
3
10 6.9
5 8.5
5 7.9
Sample Output 1:
Bank B
Sample Input 2:
500000
26
3
13 9.5
3 6.9
10 5.6
3
14 8.5
6 7.4
6 9.6
Sample Output 2:
Bank A
Input
First, you will be given N, which is the size of the matrix.
Then you will be given N rows of integers, where each row consists of N integers separated by
spaces.
Output
If the input matrix is upper triangular, then print 1. Otherwise, print 0.
12.Astronomy Lecture
Problem Statement -: Anirudh is attending an astronomy lecture. His professor who is very strict
asks students to write a program to print the trapezium pattern using stars and dots as shown below .
Since Anirudh is not good in astronomy can you help him?
Sample Input:
N=3
Output:
**.**
*…*
…..
*…*
**.**
14.Weird Terminal
Problem Statement – Here is a weird problem in Susan’s terminal. He can not write more than two
words each line, if she writes more than two, it takes only 2 words and the rest are not taken. So she
needs to use enter and put the rest in a new line. For a given paragraph, how many lines are needed to
be written in Susan’s terminal?
Input Format:
A string as the text to input in the terminal
Output Format:
Number of lines written.
Constraints:
Number of words <=10^7
Sample Input:
How long do you have to sit dear?
Sample Output:
4
Explanation:
The writing will be:
How long
Do you
Have to
Sit dear?
15. Sudoko
Given a partially filled 9×9 2D array ‘grid[9][9]’, the goal is to assign digits (from 1 to 9) to the
empty cells so that every row, column, and subgrid of size 3×3 contains exactly one instance of the
digits from 1 to 9.
Examples:
Input: grid
{ {3, 0, 6, 5, 0, 8, 4, 0, 0},
{5, 2, 0, 0, 0, 0, 0, 0, 0},
{0, 8, 7, 0, 0, 0, 0, 3, 1},
{0, 0, 3, 0, 1, 0, 0, 8, 0},
{9, 0, 0, 8, 6, 3, 0, 0, 5},
{0, 5, 0, 0, 9, 0, 6, 0, 0},
{1, 3, 0, 0, 0, 0, 2, 5, 0},
{0, 0, 0, 0, 0, 0, 0, 7, 4},
{0, 0, 5, 2, 0, 6, 3, 0, 0} }
Output:
316578492
529134768
487629531
263415987
974863125
851792643
138947256
692351874
745286319
Explanation: Each row, column and 3*3 box of the output matrix contains unique numbers.
16.The modulo operator, %, returns the remainder of a division. For example, 4 % 3 = 1 and 12 % 10
= 2. The ordinary division operator, /, returns a truncated integer value when performed on integers.
For example, 5 / 3 = 1. To get the last digit of a number in base 10, use 10 as the modulo divisor.
Task
Given a five digit integer, print the sum of its digits.
Input Format
The input contains a single five digit number, n
Constraints
Output Format
Print the sum of the digits of the five digit number.
Sample Input
10564
Sample Output
16
17. Print a pattern of numbers from 1 to n as shown below. Each of the numbers is separated by a
single space.
Input Format
The input will contain a single integer n.
Constraints
Sample Input 0
2
Sample Output 0
222
212
222
Sample Input 1
5
Sample Output 1
555555555
544444445
543333345
543222345
543212345
543222345
543333345
544444445
555555555
Sample Input 2
7
Sample Output 2
7777777777777
7666666666667
7655555555567
7654444444567
7654333334567
7654322234567
7654321234567
7654322234567
7654333334567
7654444444567
7655555555567
7666666666667
7777777777777
18. Given a string,s, consisting of alphabets and digits, find the frequency of each digit in the given
string.
Input Format
The first line contains a string, num, which is the given number.
Constraints
All the elements of num are made of english alphabets and digits.
Output Format
Print ten space-separated integers in a single line denoting the frequency of each digit from 0 to9 .
Sample Input 0
A11472o5t6
Sample Output 0
0210111100
Explanation 0
In the given string:
1 occurs two times.
2,4,5,6, and occur one time each.
The remaining digits 0,3,8 and 9 don't occur at all.
Sample Input 1
Lw4n88j12n1
Sample Output 1
0210100020
Sample Input 2
1v88886l256338ar0ekk
Sample Output 2
1112012050
19. Given a sentence,s, print each word of the sentence in a new line.
Input Format
The first and only line contains a sentence,s.
Constraints
Output Format
Print each word of the sentence in a new line.
Sample Input 0
This is C
Sample Output 0
This
is
C
Explanation 0
In the given string, there are three words ["This", "is", "C"]. We have to print each of these words in a
new line.
Sample Input 1
Learning C is fun
Sample Output 1
Learning
C
is
fun
Sample Input 2
How is that
Sample Output 2
How
is
that
20. One day three best friend’s Atul, Pandey and tony decided to form a team and take part in
programming contests. Particiants are usually offered several problems during programming
contests.Long before the start friends decide that they will implement a problem if atleast two of them
are sure about solution. othewise, friends won’t write the problem’s solution.
The contest offers n problems to the participants. For each problem we know which friend is sure
about solution. Help friends find the number of problems for which they will write a solution.
Input Format:
The first input line contains a single integer ‘n’ the number of problems in the contest. Then n line
contains three integers each integer is either 0 or 1. If the first number in the line equal 1, then Atul is
sure about the problem’s solution, otherwise he isn’t true.
The secong number shows Pandey’s view on the solution,the third number shows Tony’s view.The
number on the lines are separated by space.
21. C program to check if two given matrices are identical. First element should read elements r1 and
c1.Second element should read elements r2 and c2.Third element read with elements of matrix 1 with
space and in the NextLine it read the element of matrix 2.
If both matrices are identical print “Matrices are identical” otherwise Print “Matrices are not
identical”.
If r1 and c1, r2 and c2 are not equal print -1.
22. Consider a sample space S consisting of all perfect squares starting from 1, 4, 9 and so on. You
are given a number N, you have to output the number of integers less than N in the sample space S.
Example:
Input : N = 9
Output: 2
Explanation: 1 and 4 are the only Perfect Squares less than 9. So, the Output is 2