0% found this document useful (0 votes)
2K views250 pages

Skill Rack

Uploaded by

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

Skill Rack

Uploaded by

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

SKILL RACK

Adjacent Odd Digits

An integer N is given as input. The program must print the digits


surrounded by odd digits on both sides. The first and last digits do
not have an adjacent digit so consider it to be an odd digit.

Boundary Condition(s):
1 <= N <= 999999999999999

Input Format:
The first line contains the value N.

Output Format:
The first line contains the digits having odd adjacent digits.

Example Input/Output 1:
Input:
2353176

Output:
25316

Example Input/Output 2:
Input:
386369725

Output:
62
The program must accept an integer N as the input. The
program must print the digits surrounded by even digits on
both sides. The first and last digits have only one digit
adjacent digit to them. So consider only the single adjacent
digit for them. If there is no digit surrounded by even digits,
then the program must print -1 as the output.

Boundary Condition(s): 11 <= N <= 999999999

Input Format: The first line contains the value N.


Output Format: The first line contains either the digits having
even adjacent digits or -1.

Example Input/Output 1:

Input: 14689025
Output: 1695

Example Input/Output 2:

Input: 1357935
Output: -1
The program must accept an integer N the input. The program
must print the desired pattern as shown in the Example
Input/Output section.

Boundary Condition(s): 1 <= N <= 10^7

Input Format: The first line contains the value of N.


Output Format: The list of lines contains the desired pattern as
shown in the Example Input/Output section.

Example Input/Output 1:

Input: 8

Output: 1000
0**0
0**0
0001

Example Input/Output 2:

Input: 7
Output: 111
1*1
111
'''
Adjacent Even Digits

The program must accept an integer N as the input. The program must
print the digits surrounded by even digits on both sides. The first and
last digits have only one digit adjacent digit to them. So consider only
the single adjacent digit for them. If there is no digit surrounded by even
digits, then the program must print -1 as the output.

Boundary Condition(s):
11 <= N <= 999999999

Input Format:
The first line contains the value N.

Output Format:
The first line contains either the digits having even adjacent digits or -1.

Example Input/Output 1:
Input:
14689025

Output:
1695

Example Input/Output 2:
Input:
1357935

Output:
-1
'''
The program must accept an integer N as the input. The program
must print the 4-bit binary representation of each digit in N as the
output.

Boundary Condition(s): 1 <= N <= 10^15

Input Format: The first line contains the integer N.


Output Format: The lines contain the 4-bit binary representation of
each digit in N.

Example Input/Output 1:

Input: 4653
Output: 0100
0110
0101
0011

Example Input/Output 2:

Input: 102
Output: 0001
0000
0010
The program must accept an integer N the input. The program
must print the desired pattern as shown in the Example
Input/Output section.

Boundary Condition(s): 1 <= N <= 10^7

Input Format: The first line contains the value of N.


Output Format: The list of lines contains the desired pattern as
shown in the Example Input/Output section.

Example Input/Output 1:

Input: 8
Output: 1000
0**0
0**0
0001

Example Input/Output 2:

Input: 7
Output: 111
1*1
111
The program must accept an integer N as the input. The program
must print the 4-bit binary representation of each digit in N as the
output.

Boundary Condition(s): 1 <= N <= 10^15

Input Format: The first line contains the integer N.


Output Format: The lines contain the 4-bit binary representation of
each digit in N.

Example Input/Output 1:

Input: 4653
Output: 0100
0110
0101
0011

Example Input/Output 2:

Input: 102
Output: 0001
0000
0010
Alphabet Adjacent Pairs in Sequence

Accept a string S which contains only lower case alphabets and print the
count of instances C where in a pair of adjacent characters, the right
character is next to the left character in the original alphabetical sequence.

Boundary Condition(s):
1 <= Length of S <= 1000

Input Format:
The first line contains S.

Output Format:
The first line contains the integer value C

Example Input/Output 1:
Input:
abegh

Output:
2

Explanation:
ab gh are the two instances.

Example Input/Output 2:
Input:
abcdef

Output:
5

Explanation:
ab bc cd de ef are the five instances.
The program must accept a string S as the input. The program
must break the string into multiple string values so that each string
contains exactly one vowel. The string values must be broken such
that all the string values start with vowel except for the first string.

Boundary Condition(s): 1 <= Length of S <= 100

Input Format: The first line contains the string S.


Output Format: The lines contain a string in each line.

Example Input/Output 1:

Input: helloworld
Output: hell
ow
orld
string.

Example Input/Output 2:

Input: daefifof
Output: da
ef
if
of
The program must accept an integer array of size N containing only
0's and 1's as the input. The program must bring all the zeros to the
front and all the ones to the end of the array. Then the program must
print the modified array as the output.

Boundary Condition(s): 1 <= N <= 1000


0 <= Array Element Value <= 1

Input Format: The first line contains the value of N.


The second line contains N integers separated by space(s).

Output Format: The first line contains N integers of the modified


array separated by a space.

Example Input/Outupt 1:

Input: 7
0110100
Output: 0 0 0 0 1 1 1

Example Input/Outupt 2:

Input: 4
1110
Output: 0 1 1 1
The program must accept three floating point values as G
(gravitational constant), M (mass) and R (radius) of a planet.
The program must calculate and print the escape speed of the
object with precision up to 3 decimal places.

Formula: Escape speed = squareroot(2GM/R)

Example Input/Output 1:

Input: 1.567 2.4783 3.4671


Output: 1.497

Example Input/Output 2:

Input: 1.9038 2.7920 4.3937


Output: 1.555
The program must accept an integer N as the input. The
program must print the fibonacci series in the reverse order
as the output.

Boundary Condition(s): 5 <= N <= 85

Input Format: The first line contains the value of N.


Output Format: The first line contains the fibonacci series
separated by a space.

Example Input/Output 1:

Input: 5
Output: 3 2 1 1 0

Example Input/Output 2:

Input: 12
Output: 89 55 34 21 13 8 5 3 2 1 1 0
the program must accept an integer n as the input. the program
must print the first occurring consecutive odd digits if the first digit
is odd as the output. else the program must print the first occurring
consecutive even digits as the output.

boundary condition(s): 1 <= n <= 10^8

input format: the first line contains the integer n.


output format: the first line contains the consecutive digits without
any space.

example input/output 1:

input: 157894
output: 157

explanation: the first digit is odd so the first occurring consecutive


odd digits 1, 5 and 7 are printed.

example input/output 2:

input: 601648
output: 60
The program must accept two integers N and X as the input. The
program must print the integers from 1 to N which contains the
digit X. If there is no such integer then the program must print "-1"
as the output.

Boundary Condition(s): 1 <= N <= 10^5 0 <= X <= 9

Input Format: The first line contains the values of N and X


separated by a space.
Output Format: The first line contains either the integers from 1 to
N which contains the digit X separated by a space or -1.

Example Input/Output 1:

Input: 40 7
Output: 7 17 27 37

Example Input/Output 2:

Input: 5 9
Output: -1
Alphabets Plus Digits Sum

The program must accept a string S which has alphabets and digits as
the input. The program must find the sum of all the digits as D. Then
the program must print the alphabets which are D positions from the
alphabets present in the string.
Note:
The output must be in lowercase.
Boundary Condition(s):
Length of the S is from 3 to 100.
Input Format:
The first line contains the string S.
Output Format:
The first line contains the modified alphabets.
Example Input/Output 1:
Input:
435acl
Output:
mox
Explanation:
The digits are 4, 3, 5. The sum = 4 + 3 + 5 = 12.
The alphabets are a, c, l. So a + 12 = m, c + 12 = o, l + 12 = x.
Example Input/Output 2:
Input:
1121ZU
Output:
ez
Explanation:
The digits are 1, 1, 2, 1. The sum = 1 + 1 + 2 + 1 = 5.
The alphabets are Z, U. So z + 5 = e (circularly), u + 5 = z.
The program must accept a string S as the input. The
program must print the largest number present in the string
as the output.

Boundary Condition(s): 5 <= Length of String S <= 99

Input Format: The first line contains the value of S.


Output Format: The first line contains the largest number in
the string.

Example Input/Output 1:

Input: hello23welcome76
Output: 76

Example Input/Output 2:

Input: 9good8morning4
Output: 9
Alternate Rows Triangle Pattern

Given an integer N, the program must print the pattern as shown in


the Example Input/Output section

Boundary Condition(s):
1 <= N <= 100

Input Format:
The first line contains N.

Output Format:
The pattern is printed as shown in the Example Input/Output
section.

Example Input/Output 1:
Input:
4

Output:
---1
--3-2
-4-5-6
10-9-8-7

Example Input/Output 2:
Input:
5

Output:
----1
---3-2
--4-5-6
-10-9-8-7
11-12-13-14-15
An integer matrix of size RxC is passed as the input to the
program. The program must print the sum of elements which are
not present in the border of the matrix.

Boundary Condition(s): 2 <= R,C <= 50

Input Format: The first line contains the value of R and C


separated by space(s).
The next R lines contain C integers each separated by
space.

Output Format: The first line contains the sum of elements which
are not present along the border.

Example Input/Output 1:

Input: 4 4
18 5 5 21
23 24 1 25
8 5 15 17
23 4 29 2

Output: 45

Example Input/Output 2:

Input: 5 6
93 60 84 26 22 95
99 96 86 90 34 0
0 83 63 10 74 75
36 35 98 4 22 18
20 8 27 94 64 30

Output: 695
Alternate X Characters

Accept a string S and a position X as input. The program must print


the alternate X characters in the string by printing the first X
characters and ignoring the next X characters. This process is
repeated until the last character is reached.

Boundary Condition(s):
2 <= Length of String, S <= 1000
2 <= X <= 10

Input Format:
The first line contains the string S.
The second line contains the value of X.

Output Format:
The first line contains the string with alternate X characters.

Example Input/Output 1:
Input:
helloworld
3

Output:
helorl

Example Input/Output 2:
Input:
environmentalpollution
5

Output:
envirtalpoon
Array Adjacent Sum M Times

An array of N integers and an integer value M are given as input. The program
must calculate the sum of adjacent elements for each element for M times.

Boundary Condition(s):
2 <= N <= 1000
1 <= M <= 100

Input Format:
The first line contains N and M separated by space(s).
The second line contains N integers separated by space(s).

Output Format:
The first line contains N integers separated by a space.

Example Input/Output 1:
Input:
32
259

Output:
11 10 11

Explanation:
pass 1-> 5 11 5
pass 2-> 11 10 11

Example Input/Output 2:
Input:
53
12 13 10 8 3

Output:
34 57 63 48 29

Explanation
pass 1-> 13 22 21 13 8
pass 2-> 22 34 35 29 13
pass 3-> 34 57 63 48 29
An integer N is passed as the input to the program. The
program must print the next prime number of N as the
output. That is the smallest prime number which is greater
than N.

Boundary Condition(s): 1 <= N <= 10^17

Input Format: The first line contains the value of N.


Output Format: The first line contains the next prime number
of N.

Example Input/Output 1:

Input: 8
Output: 11

Example Input/Output 2:

Input: 29
Output: 31
The program must accept two integers X and Y as the input.
The program must print their sum S if the number of digits in S
is equal to X. Else the program must print the integer X as the
output.

Boundary Condition(s): 1 <= X, Y <= 10^8

Input Format: The first line contains the values of X and Y


separated by a space.
Output Format: The first line contains either S or X.

Example Input/Output 1:

Input: 4 997
Output: 1001

Example Input/Output 2:

Input: 8 3
Output: 8
Array Adjacent Sum M Times

An array of N integers and an integer value M are given as input. The


program must calculate the sum of adjacent elements for each element
for M times.

Boundary Condition(s):
2 <= N <= 1000
1 <= M <= 100

Input Format:
The first line contains N and M separated by space(s).
The second line contains N integers separated by space(s).

Output Format:
The first line contains N integers separated by a space.

Example Input/Output 1:
Input:
32
259

Output:
11 10 11

Explanation:
pass 1-> 5 11 5
pass 2-> 11 10 11

Example Input/Output 2:
Input:
53
12 13 10 8 3

Output:
34 57 63 48 29
'''
The program must accept N integers and an integer X as the
input. For each integer, the program must square the value of
the integer and then add X to it. Then the program must print
all the integers except the integers which are ending with 5 or
6. If the modified values of all the N integers are ending with 5
or 6 then the program must print -1 as the output.

Boundary Condition(s): 1 <= N, X <= 100


1 <= Each integer value <= 10^8

Input Format: The first line contains the values of N and X


separated by a space.
The second line contains N integers separated by
space(s).
Output Format: The first line contains either -1 or the list of
integers which do not end with 5 or 6 separated by a space.

Example Input/Output 1:

Input: 4 10
3147
Output: 19 11 59

Example Input/Output 2:

Input: 4 2
2 18 22 8
Output: -1
Array Print Every Mth Integer

An array of N integers and an integer value M are given as


input. The program must print every Mth integer in the
array.

Boundary Condition(s):
1 <= N <= 100000

Input Format:
The first line contains N and M separated by space(s).
The second line contains N integers separated by space(s).

Output Format:
The first line contains every Mth integer values separated
by a space.

Example Input/Output 1:
Input:
72
1234567

Output:
246

Example Input/Output 2:
Input:
10 3
22 72 94 29 19 27 392 28 20 67

Output:
94 27 20
The program must accept an integer N as the input. The
program must print the desired pattern as shown in the
Example Input/Output section.

Boundary Condition(s): 2 <= N <= 100

Input Format: The first line contains the value of N.


Output Format: The list of lines containing the desired pattern
as shown in the Example Input/Output section.

Example Input/Output 1:

Input: 2
Output: *()*
(())
*()*

Example Input/Output 2:

Input: 5
Output: ****()****
***(())***
**((()))**
*(((())))*
((((()))))
*(((())))*
**((()))**
***(())***
****()****
Bar Graph Pattern

Given an integer N, the program must print the pattern as shown in


the Example Input/Output section.

Boundary Condition(s):
1 <= N <= 100

Input Format:
The first line contains N.
The second line contains N integers separated by space.

Output Format:
The pattern is printed as shown in the Example Input/Output
section.

Example Input/Output 1:
Input:
3
213

Output:
--*
*-*
***

Example Input/Output 2:
Input:
6
632421

Output:
*-----
*-----
*--*--
**-*--
*****-
******
The program must accept an integer N as the input. The
program must print the sum of the first N terms in the series
given below. The order of the series must be 1, -2, 3, -4, 5, -6 and
so on (All the odd terms in the series formed from the positive
odd numbers and all the even terms in the series formed from
the negative even numbers).

Boundary Condition(s): 1 <= N <= 10^4

Input Format: The first line contains the integer N.


Output Format: The first line contains the sum of the first N
terms in the above mentioned series.

Example Input/Output 1:

Input: 5
Output: 3

Example Input/Output 2:

Input: 8
Output: -4
The program must accept an integer N as the input. The program
must print valid if N is a prime number or an even number. Else
the program must print invalid as the output.

Boundary Condition(s): 1 <= N <= 10^5

Input Format: The first line contains the integer N.


Output Format: The first line contains either valid or invalid.

Example Input/Output 1:

Input: 53
Output: valid

Example Input/Output 2:

Input: 100
Output: valid

Example Input/Output 3:

Input: 27
Output: invalid
Bomb Blast Survivors

An N*N grid is passed as input to the program. There are bombs planted in the
grid. Each bomb is detonated and destroys all the blocks in its explosion radius (If
the radius is 1, the bomb can destroy all the 8 blocks surrounding it). There are
people inside the grid represented by P. The bombs are represented by an
integer which is the explosion radius of the bombs. The program must print the
number of survivors after the explosion of all bombs.

Boundary Condition(s):
1 <= N <= 100
1 <= Explosion radius <= 9

Input Format:
The first line contains N
The next N lines contain N characters each.

Output Format:
The first line contains the count of survivors.

Example Input/Output 1:
Input:
6
**P***
****P*
*P*1**
*****P
***P*P
***PP2

Output:
2
The program must accept two integers X and Y as the input.
The program must print all the integers from X to Y which do
not have continuously repeated digits that is the digits are
repeated and all the digits in the number are same.

Boundary Condition(s): 1 <= X <= Y X <= Y <= 1000000

Input Format: The first line contains the values of X and Y


separated by space(s).
Output Format: The first line contains the integers from X to Y
which do not have continuously repeated digits.

Example Input/Output 1:

Input: 5 15
Output: 5 6 7 8 9 10 12 13 14 15

Example Input/Output 2:

Input: 1 50
Output: 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 23 24
25 26 27 28 29 30 31 32 34 35 36 37 38 39 40 41 42 43 45 46
47 48 49 50
The program must accept the value of a string S as the
input. The program must reverse all the words in S except
the first and the last word of the string. Then the program
must print the modified string value as the output.

Boundary Condition(s): 5 <= Length of S <= 999

Input Format: The first line contains the value of S.


Output Format: The first line contains the modified string
value.

Example Input/Output 1:

Input: Hi how are you


Output: Hi woh era you

Example Input/Output 2:

Input: I am fine
Output: I ma fine
Border Center Asterisk Pattern

Accept an integer N as the input. The program must print the pattern as
shown in the Example Input/Output section below. (Note:Integer N is
always odd). Asterisk is printed along the border and in the center of
the N*N matrix which is printed as the output.

Boundary Condition(s):
1 <= N <= 25

Input Format:
The first line contains the value of N.

Output Format:
The N lines contain the desired pattern.

Example Input/Output 1:
Input:
5

Ouput:
*****
*123*
*4*6*
*789*
*****

Example Input/Output 2:
Input:
3

Output:
***
***
***
Character Asterisk Alternate Pattern

An integer N is passed as the input. The program must print the pattern as
given in the Example Input/Output Section.

Boundary Condition(s):
2 <= N <= 100

Input Format:
The first line contains N.

Output Format:
The first N lines contain the pattern.

Example Input/Output 1:
Input:
3

Output:
a*b*c
*d*e*
f*g*h

Example Input/Output 2:
Input:
4

Output:
a*b*c*d
*e*f*g*
h*i*j*k
*l*m*n*
The program must accept two integers N and X as the
input. The program must reverse the last X digits in N. Then
the program must print the modified value of N as the
output.

Boundary Condition(s): 1 <= N <= 10^15 1 <= X <= 15

Input Format: The first line contains the integer N.


The second line contains the integer X.

Output Format: The first line contains the modified value of


N.

Example Input/Output 1:

Input: 12345
3
Output: 12543

Example Input/Output 2:

Input: 6745424
4
Output: 6744245
Character Between Two Vowels

Given a string S, Print only the characters which are surrounded by


vowels on both sides, if no character matches the condition print -1.

Input Format:
The first line contains the value of string S.

Output Format:
The first line contains the characters which are surrounded by vowels
on both sides if not print -1.

Boundary Condition:
3 <= length of the S <= 100

Example Input/Output 1:
Input:
acceleration

Output:
lrt

Example Input/Output 2:
Input:
knowledge

Output:
-1
Characters at Multiples of N Circularly

A string S and an integer N are given as input. The program must print
the characters present at the positions of multiples of N.
If the multiple of N goes beyond the last character, then the string
characters must be navigated in a cyclic manner till all the characters are
printed.
Each time when a character is printed, the printed character is slashed
and removed from the string.

Boundary Condition(s):
1 <= N, Length of string <= 1000

Input Format:
The first line contains S and N separated by space(s).

Output Format:
The first line contains the characters at positions of multiples of N.

Example Input/Output 1:
Input:
apple 2

Output:
plaep

Example Input/Output 2:
Input:
everything 4

Output:
rivhegnety
The program must accept a string S and an integer K as the
input. The program must reverse the middle K characters
in S. Then the program must print the modified string as
the output. Note: The length of S and the integer K are
always either odd or even.

Boundary Condition(s): 1 <= Length of S <= 100


1 <= K <= Length of S

Input Format: The first line contains the string S.


The second line contains the integer K.

Output Format: The first line contains the modified string.

Example Input/Output 1:

Input: acknowledgement
7

Output: acknegdelwoment

Example Input/Output 2:

Input: bottle
4

Output: blttoe
The program must accept a string value S as the input. The
program must print the desired pattern as shown in the
Example Input/Output section.

Boundary Condition(s): 1 <= S <= 100

Input Format: The first line contains the string S.


Output Format: The first N lines containing the desired pattern
as shown in the Example Input/Output section.

Example Input/Output 1:

Input: happy
Output: h
pa
*yp

Example Input/Output 2:

Input: orange
Output: o
ar
egn
Given a string s as the input with two or more words in it,
the program must reverse the order of the words in s.
Then the program must reverse each word in the even
positions. The resulting words in the modified order must
be printed as the output.

Boundary condition(s): 10 <= length of s <= 1000

Input format: the first line contains the string with two or
more words separated by space(s).
Output format: the first line contains the reversed string
with words in the even position reversed.

Example input/output 1:

Input: one two three four


Output: four eerht two eno example

Input/output 2:

Input: one two three four five


Output: five ruof three owt one
Check Column Palindrome Matrix

A matrix of size N*N is passed as input. The program must print yes if
there is at least one column in the matrix is a palindrome. Else the
program must print no.

Boundary Condition(s):
1 <= N <= 100

Input Format:
The first line contains N.
The next N lines contain N elements each separated by space(s).

Output Format:
The first line contains "yes" or "no".

Example Input/Output 1:
Input:
3
45 23 67
98 13 67
67 25 84

Output:
no

Example Input/Output 2:
Input:
4
34 56 14 93
76 93 76 20
86 93 16 30
34 56 14 93
The program must accept a string S and an integer N as the input. The program
must print the desired pattern as shown in the Example Input/Output section.

Boundary Condition(s): 2 <= Length of S <= 100


2 <= N <= Length of S

Input Format: The first line contains the string S.


The second line contains the integer N.

Output Format: The list of lines containing the desired pattern as shown in the
Example Input/Output section.

Example Input/Output 1:

Input: abcdefghijk
3
Output: a
*b
**c
*d
e
*f
**g
*h
i
*j
**k

Example Input/Output 2:

Input: accelerate
8
Output: a
*c
**c
***e
****l
*****e
******r
*******a
******t
*****e
Check Step Sequence

An array of N integers is passed as input. The program must print yes if


the array is a step sequence. Else the program must print no. A sequence
is said to be step sequence if the adjacent elements in the sequence
differ by exactly one for all the elements.

Boundary Condition(s):
1 <= N <= 9999

Input Format:
The first line contains N.
The second line contains N Integers separated by space(s).

Output Format:
The first line contains "yes" or "no".

Example Input/Output 1:
Input:
5
23432

Output:
yes

Example Input/Output 2:
Input:
6
567987

Output:
no
The program must accept a string S as the input. The
program must print the alphabets of S in reversal
alphabetical order as the output.

Note: The string S always contain only lowercase alphabets.

Boundary Condition(s): 1 <= Length of S <= 100

Input Format: The first line contains the string S.


Output Format: The first line contains the alphabets of S in
reversal alphabetical order.

Example Input/Output 1:

Input: orange
Output: rongea

Example Input/Output 2:

Input: sweet
Ouput: wtsee
Circular Substring

A string S is given as input. The program must print the substring of S,


given the starting and ending position of the substring. In case the end
position is less than the starting position, the substring is printed in a
circular fashion.

Boundary Condition(s):
2 <= Length of String <= 1000

Input Format:
The first line contains S, start position and end position separated by
space(s).

Output Format:
The first line contains the substring.

Example Input/Output 1:
Input:
important 2 4

Output:
por

Example Input/Output 2:
Input:
think 3 1

Output:
nkth
The program must accept an integer X followed by the brand
name or the product number of N laptops with their costs. The
program must print either the brand name or the product
number of a laptop which has the minimum cost among N
laptops. If X is 1 then X is followed by the brand name. If X is 2
then X is followed by the product number. Fill in the missing
lines of code so that the program runs successfully. Note: If two
or more laptops have the same cost then print the information
of first occurring laptop. Input Format: The first line contains
the value of N. The next N lines contain an integer, a string
(brand name) or an integer (product number) and an integer
(cost) separated by space(s). Output Format: The first line
contains either a string (brand name) or an integer (product
number) of the laptop which has the minimum cost among N
laptops.

Example Input/Output 1:

Input: 4
1 Sony 70000
2 89793456 30000
2 65765767 60000
1 HP 45000
Output: 89793456

Example Input/Output 2:

Input: 3
1 Samsung 50000
2 76576777 45000
1 Acer 20000
Output: Acer
Circular Track to Reach Initial Position

A circular track has N positions numbered from 1 to N. The initial


position I of the player and an integer M are given as the input. The
player jumps M positions per move. The program must print the
minimum number of moves required to reach the initial position again.

Boundary Condition(s):
1 <= N <= 1000
1 <= I <= N
1 <= M <= 1000

Input Format:
The first line contains the value of N, I and M.

Output Format:
The first line contains the number of moves.

Example Input/Output 1:

Input:
10 2 5

Output:
2

Explanation:
2->7->2

Example Input/Output 2:

Input:
70 15 12

Output:
35
The program must accept an integer N and a digit D as the
input. The program must print the sum of the integers from 1 to
N which have the unit digit as D as the output. If there is no
such integer from 1 to N then the program must print -1 as the
output.

Boundary Condition(s): 1 <= N <= 1000 0 <= D <= 9

Input Format: The first line contains the values of N and D


seperated by space.
Output Format: The first line contains either the sum of the
integers from 1 to N which have the unit digit as D or -1.

Example Input/Output 1:

Input: 30 3
Output: 39

Example Input/Output 2:

Input: 5 7
Output: -1
The program must accept an integer matrix of size rxc as the
input. the program must print the sum of top left quadrant
elements as the output.

Boundary condition(s): 1 <= r, c <= 99

Input format: the first line contains the integer values r and c
separated by space(s).
the next r lines contain c integers each separated by
space.
Output format: the first line contains the sum of top left
quadrant elements.

Example input/output 1:

Input: 4 4
1234
5678
9123
4567
Output: 14
Common Alphabets N Strings

N string values are passed as input to the program. Each string will contain only
the alphabets a-z in lower case. A given alphabet may be repeated any number of
times. The program must print the count C of the alphabets that are present in all
the N string values.

Input Format:
The first line contains N.
Next N lines contain the N string values.

Output Format:
The first line contains C.

Boundary Conditions:
2 <= N <= 500
1 <= Length of the string value <= 1000

Example Input/Output 1:
Input:
3
mnppqqr
ajkmnnm
poormanagement

Output:
2

Explanation:
Only 2 alphabets m and n are present in all the three string values.

Input:
5
ptkogphdtykhbgvqmykw
pnmcbtqodtdqjaeyayyp
yfvepcwyqyonglozltjo
nxfhvacwpvtxsrtvhwpt
dsaadnwrdpaqbalybvge

Expected Output:
1
Consecutive Characters from Two Strings

Two strings S1 and S2 are given as the input. If two alphabets from the string S2
occur consecutively in string S1, the second alphabet must be removed from
string S1. The program must print the string S1 after removing such occurrences.

Boundary Condition(s):
1 <= Length of S1 <= 1000
1 <= Length of S2 <= 26

Input Format:
The first line contains S1.
The second line contains S2.

Output Format:
The first line contains a string.

Example Input/Output 1:
Input:
technology
echgy

Output:
tenolog

Explanation:
Two characters ec from s2 consecutively occur in technology. So the second
alphabet c is removed and technology becomes tehnology.
Two characters eh from s2 consecutively occur in tehnology. So the second
alphabet h is removed and tehnology becomes tenology.
Two characters gy from s2 consecutively occur in tenology. So the second
alphabet y is removed and tenology becomes tenolog.

Example Input/Output 2:
Input:
imagination
ahtng

Output:
imainion
1 An array of N integers is passed as the input to the program.
The program must print the sum of all the elements present
to the left of each element as the output.

Input: 5
2 4 6 8 10
Output: 0 2 6 12 20

2 Alternate letters in uppercase


A str‌ing (only alphabets) is passed as input.
The printed output should contain alphabets in odd positions
in each word in uppercase and alphabets in even positions in a
word in lowercase.

Example input and output:


If the input is 'tREE GiVES us fruiTS', the output should be 'TrEe
GiVeS Us FrUiTs'
If the input is 'FLoweR iS beauTIFUL', the output should be
'FlOwEr Is BeAuTiFuL'
Max Execution Time Limit: 10000 millisecs
The program must accept N integers as the input. If N is even,
the program must print the sum of middle four integers among
N integers as the output. Else the program must print the sum
of middle three integers among N integers as the output.

Boundary Condition(s): 5 <= N <= 100 1 <= Each Integer Value


<= 9999

Input Format: The first line contains the integer N.


The second line contains N integers separated by
space(s).

Output Format: The first line contains either the sum of middle
four integers or the sum of middle three integers among N
integers.

Example Input/Output 1:

Input: 5
23576
Output: 15

Example Input/Output 2:

Input: 6
23 47 63 52 77 56
Output: 239
The program must accept an integer N as the input. The
program must print the desired pattern as shown in the
Example Input/Output sections.

Boundary Condition(s): 1 <= N <= 20

Input Format: The first line contains the integer N.


Output Format: The list of lines contain the desired pattern.

Example Input/Output 1:

Input: 5
Output: 0
505
45054
3450543
234505432
12345054321

Example Input/Output 2:

Input: 4
Output: 0
404
34043
2340432
123404321
The program must accept a string S as the input. The
program must toggle the case of vowels in the string S. Then
the program must print the modified string as the output.

Boundary Condition(s): 1 <= Length of S <= 100

Input Format: The first line contains the string S.

Output Format: The first line contains the modified string.

Example Input/Output 1:

Input: EquilIbriUm
Output: eqUIlibrIum

Example Input/Output 2:

Input: JUNKVIRUS
Output: JuNKViRuS
The program must accept an integer N as the input. The
program must print the desired pattern as shown in the
Example Input/Output section.

Boundary Condition(s): 1 <= N <= 10^15

Input Format: The first line contains the integer N.


Output Format: The list of lines containing the desired pattern
as shown in the Example Input/Output section.

Example Input/Output 1:

Input: 43785
Output: 4
33
777
8888
55555

Example Input/Output 2:

Input: 10001
Output: 1
00
000
0000
11111
An N*N matrix containing 1s and 0s is given as the input to the
program. The program must print the number of 2x2 unit
matrices in the given matrix. A matrix is said to be unit matrix if
all the integers are 1. Also, consider the overlapping matrices.

Boundary Condition(s): 1 <= N <= 100

Input Format: The first line contains the value of N.


The next N lines contain N elements each separated by
space(s).
Output Format: The first line contains an integer value.

Example Input/Output 1:

Input: 3
101
111
110
Output: 1
Example Input/Output 2:

Input: 4
1011
1111
1100
0000
Output: 2
The program must a string S as the input. The program must
print all the vowels in the string followed by all the
consonants in the string as the output.

Boundary condition(s): 1 <= length of s <= 200

Example input/output 1:

Input: elephant
Output: eealphnt

Example input/output 2:

Input: HETEROGENEOUS
Output: EEOEEOUHTRGNS
The program must accept an integer N as the input. The
program must print the pattern as shown in the Example
Input/Output sections.

Boundary Condition(s): 5 <= N <= 50

Input Format: The first line contains the value of N.


Output Format: The first N lines contain the desired pattern
as shown in the Example Input/Output sections.

Example Input/Output 1:

Input: 15
Output: ***************
**-----------**
*-*---------*-*
*--*-------*--*
*---*-----*---*
*----*---*----*
*-----*-*-----*
*------*------*
*-----*-*-----*
*----*---*----*
*---*-----*---*
*--*-------*--*
*-*---------*-*
**-----------**
***************
Rook Game
Two players A and B are playing a game. In that game, there is a chessboard of size R*C, where
they take turns placing the rooks. The cells with the rook are represented by 1. The empty cells
are represented by 0. In each turn, a player must place a rook.

A rook may be placed on the basis of the following conditions.


- The cell must be an empty cell.
- There should be no rook in the row and column of the cell.

When a player is unable to make a move, he loses and the game ends. The initial state of the
chessboard is passed as the input to the program. The program must print the winner of the
game if player A starts the game.
Note: Both the players have an infinite number of rooks to play the game.

Input Format:
The first line contains R and C separated by a space.
The next R lines, each contains C integers separated by a space.

Output Format:
The first line contains A or B.

Example Input/Output 1:
Input:
33
100
000
100

Output:
A

Example Input/Output 2:
Input:
32
11
01
10

Output:
B
Example Input/Output 3:
Input:
22
00
00
Output:
B
Emptying Water from Buckets
There are N buckets arranged in a row. Each bucket has a certain amount of water. The
maximum capacity and the amount of water in each bucket are passed as the input. A boy
performs N-1 operations based on the following conditions.
- In the first operation, he empties the 1st bucket into the 2nd bucket (i.e., pouring water from
the 1st bucket into the 2nd bucket).
- In the second operation, he empties the 2nd bucket into the 3rd bucket.
- Similarly, he performs the remaining operations.
- During the emptying operation, if the next bucket is full and some water is remaining in the
current bucket, the water will be kept in the same bucket.
After N-1 operations, the program must print the amount of water in the last bucket and the
total amount of water remaining in the first N-1 buckets.

Input Format:
The first line contains N.
The second line contains N integers separated by a space representing the maximum
capacities of the N buckets.
The third line contains N integers separated by a space representing the amount of water in the
N buckets.

Output Format:
The first line contains two integers separated by a space representing the amount of water in
the last bucket and the total amount of water remaining in the first N-1 buckets.

Example Input/Output 1:
Input:
3
345
134

Output:
53

Example Input/Output 2:
Input:
3
323
000

Output:
00

Example Input/Output 3:
Input:
4
10 20 30 40
2222

Output:
80
function countDivisibleByThree
The function/method countDivisibleByThree accepts an argument str
representing a string value. The string str contains only digits and it represents an
integer.

The function/method countDivisibleByThree must return an integer denoting the


number of integers divisible by 3 that can be obtained by changing at most one
digit in the given string.

Your task is to implement the function countDivisibleByThree so that the


program runs successfully.

IMPORTANT: Do not implement the main() function as it is already defined.

Boundary Condition(s):
1 <= Length of the given string <= 100

Example Input/Output 1:
Input:
23

Output:
7

Explanation:
The 7 possible ways are given below.
03, 21, 24, 27, 33, 63 and 93.

Example Input/Output 2:
Input:
100

Output:
10

Example Input/Output 3:
Input:
28041587931619954605240353727

Output:
69
function countDivisibleByThree
The function/method countDivisibleByThree accepts an argument
str representing a string value. The string str contains only digits
and it represents an integer.

The function/method countDivisibleByThree must return an


integer denoting the number of integers divisible by 3 that can be
obtained by changing at most one digit in the given string.

Your task is to implement the function countDivisibleByThree so


that the program runs successfully.

IMPORTANT: Do not implement the main() function as it is already


defined.

Boundary Condition(s):
1 <= Length of the given string <= 100

Example Input/Output 1:
Input:
23

Output:
7

Example Input/Output 2:
Input:
100

Output:
10

Example Input/Output 3:
Input:
28041587931619954605240353727

Output:
69
Replace Color - Adjacent Pixels
The program must accept a character matrix of size R*C representing an image, the
location of a pixel in the image (X, Y) and a color CH as the input. The program must replace
the color of the given pixel and all adjacent same colored pixels with the color CH (all 8
possible directions). Finally, the program must print the revised matrix as the output.

Input Format:
The first line contains R and C separated by a space.
The next R lines, each contains C characters separated by a space.
The R+2nd contains X, Y and CH separated by a space.

Output Format:
The first R lines contain the revised matrix.

Example Input/Output 1:
Input:
43
BBW
WWW
WWW
BBB
22G

Output:
BBG
GGG
GGG
BBB

Example Input/Output 2:
Input:
56
RGRYYY
GRGYRR
RRRYRR
GRGYYY
GRRRGG
42P

Output:
PGPYYY
GPGYRR
PPPYRR
GPGYYY
GPPPGG
Assign Question Paper to Student
A class teacher has 26 sets of question papers named from A to Z. He
wants to conduct a test for his class students. Each student has a
registration number. He assigns a question paper to each student based
on the following condition.
- Find the sum of all the digits in the registration number. If the sum is
within the range 1-26, then the corresponding question paper set is
assigned to the student. Else the sum of the digits is calculated again and
again til the sum falls within the range 1-26, and then the corresponding
question paper set is assigned to the student.
The program must accept an integer R representing the registration
number of a student as the input. The program must print the name of the
question paper set assigned to the student as the output.

Boundary Condition(s):
1 <= R <= 10^9

Input Format:
The first line contains R.

Output Format:
The first line contains an alphabet representing the name of the question
paper set assigned to the student.

Example Input/Output 1:
Input:
100954

Output:
S

Example Input/Output 2:
Input:
9223399

Output:
J
Substring & Repeated String
The program must accept two string values S1 and S2 as the input. The
program must print YES if S1 can be formed when S2 is repeated any number
of times. Else the program must print NO as the output.

Boundary Condition(s):
1 <= Length of S2 <= Length of S1 <= 100

Input Format:
The first line contains S1.
The second line contains S2.

Output Format:
The first line contains either YES or NO.

Example Input/Output 1:
Input:
antantan
ant

Output:
YES

Example Input/Output 2:
Input:
bookbookbook
ookb

Output:
YES

Example Input/Output 3:
Input:
SkillRack
llRackSkl

Output:
NO
Power of 2 Matrix
The program must accept an integer N as the input. The program must form an
integer matrix of size (2^N)*(2^N). The program must fill the matrix with the
integers submatrix by submatrix of size 2*2 in the order (Top-left, Top-right, Bottom-
left and Bottom-right) as shown in the Example Input/Output section.

Boundary Condition(s):
1 <= N <= 7

Input Format:
The first line contains N.

Output Format:
The first 2^N lines contain the integer matrix as shown in the Example Input/Output
section.

Example Input/Output 1:
Input:
3

Output:
1 2 5 6 17 18 21 22
3 4 7 8 19 20 23 24
9 10 13 14 25 26 29 30
11 12 15 16 27 28 31 32
33 34 37 38 49 50 53 54
35 36 39 40 51 52 55 56
41 42 45 46 57 58 61 62
43 44 47 48 59 60 63 64

Example Input/Output 2:
Input:
2

Output:
1256
3478
9 10 13 14
11 12 15 16

Example Input/Output 3:
Input:
1

Output:
12
34
Validate Variable Name
The program must accept a string S representing a variable name as the input. The
program must validate the given variable name based on the following conditions.
- Only English letters, digits and underscore are allowed.
- The variable name must not start with digits.
The program must print YES if the given variable name is valid. Else the program must
print NO as the output.

Boundary Condition(s):
1 <= Length of S <= 50

Input Format:
The first line contains S.

Output Format:
The first line contains YES or NO.

Example Input/Output 1:
Input:
Max_1_count

Output:
YES

Example Input/Output 2:
Input:
2_min

Output:
NO

Example Input/Output 3:
Input:
onesCount#1

Output:
NO

Example Input/Output 4:
Input:
max Value

Output:
NO
function findMaximum
The function/method findMaximum accepts four arguments R, C, matrix and K. The first two arguments R and C
represent the size of an integer matrix. The third argument represents the R*C integer matrix. The fourth
argument represents an integer value.

The function/method findMaximum must form an integer matrix of size M*N, where M = R/K and N = C/K. Then
the function must fill the matrix with the maximum value in each K*K submatrix of the given matrix. Finally, the
function must return the M*N matrix.

Note: The values of R and C are always divisible by K.

Your task is to implement the function findMaximum so that it passes all the test cases.

The following structure is used to represent the boundedArray and is already defined in the default code (Do not
write this definition again in your code).
typedef struct BoundedArray
{
int M, N;
int **matrix;
} boundedArray;

Example Input/Output 1:
Input:
99
18 38 31 65 47 68 96 49 31
30 23 83 78 38 19 24 94 43
24 17 49 21 94 84 86 53 78
43 67 64 42 68 13 95 85 64
27 54 69 76 43 37 92 19 26
61 58 84 85 83 36 11 17 15
20 24 50 74 58 17 40 20 90
82 31 24 88 78 68 67 24 72
69 24 87 41 32 68 37 79 80
3

Output:
83 94 96
84 85 95
87 88 90

Example Input/Output 2:
Input:
68
26 13 27 55 35 51 78 24
72 83 25 80 34 10 60 17
14 36 38 77 67 47 41 15
61 69 42 82 63 86 43 56
66 22 19 53 87 12 57 50
81 49 46 44 23 90 62 11
2

Output:
83 80 51 78
69 82 86 56
81 53 90 62
Sum - Digits on Left and Right
The program must accept an integer N containing only nonzero
digits as the input. For each digit D in the integer N, the program
must form an integer by concatenating D digits on the left and
D digits on the right of the D. Then the program must print the
sum of the resulting integer values. If the number of digits on
the left or right is less than D, then consider only the existing
digits on the left or right.

Boundary Condition(s):
10 <= N <= 10^8

Input Format:
The first line contains N.

Output Format:
The first line contains an integer value representing the sum of
resulting integer values.

Example Input/Output 1:
Input:
2314

Output:
510

Example Input/Output 2:
Input:
541326

Output:
201089
Print between Repeated Characters
The program must accept a string S as the input. The program must print the characters between
the repeated characters(inclusive) as the output. If there are no repeating characters, then the
program must print -1 as the output.

Boundary Condition(s):
2 <= Length of S <= 1000

Input Format:
The first line contains S.

Output Format:
The lines contain the characters between the repeated characters(inclusive) or -1 as the output.

Example Input/Output 1:
Input:
skillrack

Output:
killrack
ll

Example Input/Output 2:
Input:
qualification

Output:
alifica
ifi
icati

Example Input/Output 3:
Input:
svghakjufr

Output:
-1

Example Input/Output 4:
Input:
bbaabbaabb

Output:
bb
baab
bb
baab
bb
aa
abba
Sorted List with Duplicates
Hector forms a list of integers that contains only positive integers in ascending order. The
program must accept N integers representing the integers to be inserted or removed in the list.
Initially, the list is empty. For each integer X among the N integers, the program must insert the
integer X into the sorted list if X is positive. Otherwise, the program must remove one
occurrence of the absolute value of X from the list(if exists). After each insert/remove
operation, the program must print the integers in the list. If there is no integer in the list, then
the program must print EMPTY as the output.
Input Format:
The first line contains N.
The second line contains N integer values separated by a space.

Output Format:
The first N lines, each contains integer values separated by a space or the string value EMPTY.

Example Input/Output 1:
Input:
11
10 30 10 20 10 20 10 -10 -40 20 -30

Output:
10
10 30
10 10 30
10 10 20 30
10 10 10 20 30
10 10 10 20 20 30
10 10 10 10 20 20 30
10 10 10 20 20 30
10 10 10 20 20 30
10 10 10 20 20 20 30
10 10 10 20 20 20

Example Input/Output 2:
Input:
8
-50 35 25 15 -25 -15 -35 50

Output:
EMPTY
35
25 35
15 25 35
15 35
35
EMPTY
50
Count the 1s in the binary representation
A positive integer N is passed as the input. The program
must print the number of 1s in the binary representation of
N.

Input Format:
First line contains N.

Output Format:
First line contains the count of 1s in the binary
representation of N.

Boundary Conditions:
1 <= N <= 9000000000000000000

Example Input/Output 1:
Input:
22

Output:
3
function incrementRowWise
The function/method incrementRowWise accepts three arguments R, C
and matrix. The integers R and C represent the size of the integer matrix.

The function/method incrementRowWise must modify the given matrix by


incrementing the value of each integer by its row position (i.e., Increment
each integer in the 1st row by 1, increment each integer in the 2nd row by
2, increment each integer in the 3rd row by 3, and so on).

Your task is to implement the function incrementRowWise so that the


program runs successfully.

IMPORTANT: Do not implement the main() function as it is already defined.

Example Input/Output 1:
Input:
33
123
456
789

Output:
234
678
10 11 12

Example Input/Output 2:
Input:
45
10 20 30 40 50
8 18 28 38 48
55 44 33 22 11
6 7 8 9 10

Output:
11 21 31 41 51
10 20 30 40 50
58 47 36 25 14
10 11 12 13 14
Isomorphic Strings
Given two strings S1 and S2, the program must print if they are
isomorphic or [Link] strings are isomorphic if the characters in
S1 can be replaced to get S2 based on the conditions given below.
- All occurrences of a character must be replaced with another
character while preserving the order of characters.
- No two characters can map to the same character but a
character can map to itself.

Input Format:
The first line contains S1
The second line contains S2
Output Format:
The first line contains YES or NO indicating if S1 and S2 are
isomorphic or not.

Boundary Conditions:
1 <= Length of S1 and S2 <= 1000

Example Input/Output 1:

Input:
fill
bell

Output:
YES

Example Input/Output 2:
Input:
paper
title
Output:
YES
Example Input/Output 3:
Input:
pen
egg
Output:
NO
Max Execution Time Limit: 5000 millisecsA
Count Binary Value in Matrix

Accept an integer matrix with size RxC and N as input, the matrix contains only 0's and 1's. The
program must print the count of the binary value of N present in the matrix (row-wise and
column-wise).

Boundary Condition(s):
1 <= R, C <= 49
1 <= N <= 100

Input Format:
The first line contains the integer value of R and C separated by space.
The next R lines contain C integers each separated by space.
The R+2th line contains the integer value of N.

Output Format:
The first line contains the count of the binary value of N present in the matrix (row-wise and
column-wise).

Example Input/Output 1:
Input:
45
10101
00000
11111
10100
5

Output:
6

Example Input/Output 2:
Input:
55
10010
01011
00100
10000
01000
4

Output:
9
Electronic Display - Maximum Value
In a four-digit electronic display, each digit is displayed using seven segments. The
program must accept an integer N representing the number of segments to display an
integer X. The program must print the maximum possible four-digit integer X that can be
displayed using N segments as the output.
The number of segments required to display each digit is given below.
0-6
1-2
2-5
3-5
4-4
5-5
6-6
7-3
8-7
9-6

Boundary Condition(s):
8 <= N <= 28

Input Format:
The first line contains N.

Output Format:
The first line contains X.

Example Input/Output 1:
Input:
13

Output:
9711

Example Input/Output 2:
Input:
10

Output:
7711

Example Input/Output 3:
Input:
18

Output:
9977
Count of Uppercase Letters

A string is passed as input. The program must print the count of


uppercase letters.

Boundary Condition(s):
1 <= length of string <= 1000

Input Format:
The first line contains the string.

Output Format:

The first line contains the count of uppercase letters.

Example Input/Output 1:
Input:
aPpLe

Output:
2

Example Input/Output 2:
Input:
MoNGoDB

Output:
5
Split Sum - Floating Point Values
The program must accept N floating point values as the input. The program
must divide the given N floating point values into the following two
categories.
1) The floating point values are greater than X.5, where X is the integer part of
a floating point value.
2) The floating point values are less than or equal to X.5, where X is the integer
part of a floating point value.
Finally, the program must print the sum of the integer parts of the floating
point values in both categories separated by a space as the output.

Boundary Condition(s):
1 <= N <= 100
1.00000 <= Each floating point value <= 99999.99999

Input Format:
The first line contains N.
The second line contains N floating point values separated by a space.

Output Format:
The first line contains two integers separated by a space representing the two
sum values based on the given conditions.

Example Input/Output 1:
Input:
5
100.50001 12.5 10.45 9.501 20.49999

Output:
109 42

Example Input/Output 2:
Input:
6
1.5 2.1 3.0 10.6 10.99 5.51

Output:
25 6
Define class Travels
A travel company receives N booking requests. Each booking request contains the source city, the
destination city and the number of persons. Each bus in the travels has a maximum of X seats. The
program must accept the N booking requests and the value of X as the input. For each booking
request, the program must process the request and print the output based on the following
conditions.
- If the number of seats remaining in the bus (from the given source to the given destination) is
greater than or equal to the number of persons in the booking request, then the seats must be
booked and the program must print "Booked Successfully".
- Else the program must print "Failed" as the output.

Your task is to define the class Travels so that the program runs successfully.

The calling code [Link] is as given below.


from travels import Travels

N, X = map(int, input().split())
travels = Travels(X)
for ctr in range(N):
src, dest, count = input().strip().split()
print("Booked Successfully" if [Link](src, dest, int(count)) else "Failed")

Example Input/Output 1:
Input:
10 5
Trichy Coimbatore 10
Chennai Bangalore 2
Bangalore Chennai 5
Chennai Bangalore 3
Coimbatore Trichy 4
Trichy Coimbatore 1
Bangalore Chennai 1
Chennai Bangalore 4
Trichy Coimbatore 5
Trichy Coimbatore 2

Output:
Failed
Booked Successfully
Booked Successfully
Booked Successfully
Booked Successfully
Booked Successfully
Failed
Failed
Failed
Booked Successfully
Example Input/Output 2:
Input:
9 15
Bangalore Dindigul 8
Madurai Salem 11
Bangalore Dindigul 15
Hosur Bangalore 10
Hosur Bangalore 3
Theni Coimbatore 12
Hosur Bangalore 4
Theni Hosur 18
Trichy Theni 1

Output:
Booked Successfully
Booked Successfully
Failed
Booked Successfully
Booked Successfully
Booked Successfully
Failed
Failed
Booked Successfully
Crop Water Calculator

A farmer wants to plant paddy crops in his farm. So he visited a near by agriculture
shop to buy seeds. The shopkeeper showed the farmer various varieties of paddy
seed. Each variety of paddy seed varies from one another especially on the
Number of Days D needed to water and it's Growth Rate G. The quantity of water in
certain units required by a single crop in a single day is same as the growth rate on
that particular day. The Growth Rate G reduces by a value R everyday which will
reduce the water consumption by crops. The shopkeeper issued S number of seeds
to the farmer and assuming all seeds will grow, write a program to find the units of
Water Consumption W for D days.

Input Format:
The first line contains the value of Number of Seeds S, Growth Rate G, Number of
Days D to grow and the Reduction in Growth Rate R each separated by a space.

Output Format:
The first line contains the total units of Water Consumption W in D days.

Boundary Conditions:
1 <= S, G, D, R <= 999999

Example Input/Output 1:
Input:
10 5 5 1

Output:
150

Explanation:
The total number of seeds S the farmer will buy is 10.
The number of days D the crop has to be watered is 5
The growth rate G of each seed is 5.
The growth rate G is reduced by R-value 1 on every day. So, for the day 1 G is 5, day
2 G is 4, day 3 it is 3 and so on.
The Water Consumption W for 5 days = 10*5 + 10*4 + 10*3 + 10*2 + 10*1 = 150 units

Example Input/Output 2:
Input:
100 10 10 0

Output:
10000
Decreasing Sequence with Difference Decreasing

Two integers N and D are passed as input. The program must


print the decreasing sequence from N with common difference
D. The difference D is decremented by 1 when calculating the
values every time. The sequence is printed until D becomes zero.

Boundary Condition(s):
2 <= N <= 9999999
1 <= D <= 9999999

Input Format:
The first line contains N and D separated by space(s).

Output Format:
The first line contains integers separated by a space.

Example Input/Output 1:
Input:
20 5

Output:
15 11 8 6 5

Example Input/Output 2:
Input:
12 6

Output:
6 1 -3 -6 -8 -9
Insert between Characters
The program must accept a string S (which does not contain any
space) and another character CH. The program must insert the
character CH between every adjacent pairs of characters in the string
S.

Boundary Condition(s):
1 <= Length of S <= 100

Input Format:
The first line contains S.
The second line contains CH.

Output Format:
The first line contains a string value.

Example Input/Output 1:
Input:
abcde
:

Output:
[Link].

Example Input/Output 2:
Input:
k

Output:
k

Example Input/Output 3:
Input:
on
-

Output:
o-n
Deliver from Farm to Shops

A truck needs to deliver vegetables from a farm to several shops. The


truck driver has decided to visit the nearest shop from the farm first
and then the second nearest shop from the farm and so on. To travel
from farm to the shops, the truck has to travel through cities. There are
N roads (one-way) connecting two different locations (Location can be
any of these - farm, city or shop) are passed as input. The farm has no
incoming road and the shops have no outgoing road. Print the shops in
the order of their visit by the truck. (Hint: Cities are identified by the
fact that they have outgoing roads.)

Note: The distance from the farm to a shop is calculated by the number
of cities it has to cross to reach the shop.

Boundary Condition(s):
1 <= N <= 100

Input Format:
The first line contains N.
The next lines contain the name of the two locations (source and
destination) connected by a road separated by space(s).

Output Format:
The first line contains the name of the shops separated by a space.

Example Input/Output 1:
Input:
5
farm mid1
mid1 mid2
mid2 shop1
mid2 mid3
mid3 shop2

Output:
shop1 shop2
Matrix Sum - L or Inverted L
The program must accept an integer matrix of size N*N as the input. The program
must find the sum of integers in the L-shape and inverted L-shape of the matrix. If
the sum of the integers in L-shape and the sum of the integers in inverted L-shape
are equal then print YES as the output. Else the program must print NO as the
output.

Input Format:
The first line contains N.
The next N lines each contain N integers separated by a space.

Output Format:
The first line contains either YES or NO.

Example Input/Output 1:
Input:
4
1634
2342
3455
4567

Output:
YES

Example Input/Output 2:
Input:
5
7 27 20 60 67
82 77 12 74 32
98 14 62 1 77
45 11 55 6 92
27 30 30 27 8

Output:
NO

Example Input/Output 3:
Input:
7
5484262
2971123
1327233
2386798
6451421
8293213
7425437

Output:
YES
String with Three Integers
The program must accept two nonzero digits D1, D2 and a string S as the input. The program
must form three integers A, B and C based on the following conditions.
A = D1
B = (A*10)+D2
C = (B*10)+D2
The program must print Yes if the given string S is formed by the concatenation of integers
A, B and C (in any order and any number of times). Else the program must print No as the
output.

Note:
- The values of D1 and D2 are always not equal.
- The string S always contains nonzero digits.

Input Format:
The first line contains D1 and D2 separated by a space.
The second line contains S.

Output Format:
The first line contains Yes or No.

Example Input/Output 1:
Input:
13
11313313

Output:
Yes

Example Input/Output 2:
Input:
52
25222

Output:
No

Example Input/Output 3:
Input:
69
696969677

Output:
No
Pattern Printing - 005
Given an integer N as the input, the program must print 2N lines pattern output as described in the
Example Input/Output given below.

Input Format:
The first line contains N.
Output Format:
2N lines of the pattern.

Example Input/Output 1:
Input:
4
Output:
1
22
333
4444
4444
333
22
1

Example Input/Output2:
Input:
10
Output:
1
22
333
4444
55555
666666
7777777
88888888
999999999
10101010101010101010
10101010101010101010
999999999
88888888
7777777
666666
55555
4444
333
22
1

Max Execution Time Limit: 5000 millisecs


Digital 7-Shaped String

Given an input String S, accept the input string S and print the string
as shown in the Example Input/ Output section.

Input Format:
The first line contains the value of the string S. S may contain
alphabets, numbers and special characters.

Output Format:
The strings are printed in the Digital 7-Shaped format.

Boundary Conditions:
1 < Length of S <1000

Example Input/ Output 1:


Input:

xyz

Output:
xxx
yyx
zyx

Example Input/ Output 2:


Input:
123456

Output:
111111
222221
333321
444321
554321
654321
Sanath rsean's encryption quest!
One day sean's friend john wanted him to encrypt a few messages that were to be sent via a
telegram group, so that everyone could see the message, but
only those special people who knew decryption can actually understand it. help sean write a code
that take input values of the type of encryption, a key, and a message to be encrypted that had
something to do with the [Link] format:first line containing the type of encryption [Link] line
containing the
key [Link] line containing the message m.

output format:
the first line contains the encrypted message.

Note:
The encryption process is based on the simple logic of addition, that is simply adding the value of
the key(/modified key) to the characters of the message to be encrypted. only upper case
alphabets need to be considered.x is a number -1 or 0 or 1,\
a) -1 denotes the decreasing value of the key
b) 0 denotes the constant value of the key
c) 1 denotes the increasing value of the keyd) in case of invalid input value of x simply display
“invalid input”.

if the input value of k is less than or equal to 0, make the initial value of k as 1
Boundary conditions:
The maximum length of the message m is 200 and it's minimum length is 1

example input/output 01:


input:
1
2
summer

output:
uxqrky

example input/output 02:


input:
-1
6
holiday
output:
ntplfby
i
input:
0
2
entertainment
output:
gpvgtvckpogpv
example input/output04:
input:
-1
1
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
output:
azyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcbazyxw
vutmax

execution time limit: 3000 millisecs


Cut & Remove Rods
The program must accept N integers representing the length of N rods. A boy cuts the
rods into smaller rods based on the following conditions.
- He finds the length of the shortest rod. Then he cuts that length from each of the
longer rods and then he removes all the pieces of the shortest length. When all the
remaining rods are the same length, they cannot be shortened so he removes those
rods.
- He repeats the above process until there are no rods left.
The program must print the number of rods remaining before each cutting process.

Boundary Condition(s):
1 <= N, Length of each rod <= 1000

Input Format:
The first line contains N.
The second line contains N integers separated by a space representing the length of N
rods.

Output Format:
The lines contain the integer values based on the given conditions.

Example Input/Output 1:
Input:
6
842278

Output:
6
4
3
2
Example Input/Output 2:
Input:
9
123454321

Output:
9
7
5
3
1
Divisible By Both 2 and 3

An array of N integers is given as input. The program must print


the integers which are divisible by both 2 and 3.

Boundary Condition(s):
1 <= N <= 10000

Input Format:
The first line contains the value of N.
The second line contains N integers separated by space(s).

Output Format:
The first line contains the integers divisible by both 2 and 3
separated by a space.

Example Input/Output 1:
Input:
5
8 6 12 9 24

Output:
6 12 24

Example Input/Output 2:
Input:
7
22 24 67 60 93 96 102

Output:
24 60 96 102
function areConsecutive
The function/method areConsecutive accepts an argument str. The
string str contains only [Link] function/method areConsecutive must
return 1 if the given string represents the concatenation of two
consecutive integers. Else the function must return [Link] task is to
implement the function areConsecutive so that the program runs
successfully.

IMPORTANT: Do not write the main() function as it is already defined.

Example Input/Output 1:

Input:
256257
Output:
1

Example Input/Output 2:

Input:
4241
Output:
1

Example
Input/Output 3:
Input:
99100
Output:
1

Example Input/Output 4:
Input:
20412024
Output:
0
Dynamic V Pattern

The program must accept two integers (X, Y) and a character CH as the input. The
program must print the desired pattern as shown in the
Example Input/Output section.
Boundary Condition(s):
1 <= X, Y <= 1000
Input Format:
The first line contains the values of X, CH and Y separated by a space.
Output Format:
The list of lines containing the desired pattern as shown in the Example Input/Output
section.
Example Input/Output 1:
Input:
3#5
Output:
------#
-----#
#---#
-#-#
--#
Example Input/Output 2:
Input:
7@7
Output:
@-----------@
-@---------@
--@-------@
---@-----@
----@---@
-----@-@
------@
Example Input/Output 3:
Input:
10 * 4
Output:
*
-*
--*
---*
----*
-----*
------*-----*
-------*---*
--------*-*
---------*
Equidistant Characters from Start & End

Given a string value S1 the program must print only the characters
which are present in the same position from the start of S1 as well as
the end of S1 in the order of their occurrence.

Boundary Condition(s):
1 <= Length of S1 <= 1000

Input Format:
The first line contains S1.

Output Format:
The first line contains the string value containing the characters
which are present in the same position from the start of S1 as well as
the end of S1.

Example Input/Output 1:
Input:
engine

Output:
en

Example Input/Output 2:
Input:
malayalam

Output:
malay
Maximum Sum - No Adjacent
The program must accept an integer matrix of size 2*N as the input. The program
must print the maximum sum such that no two chosen integers are adjacent
vertically, diagonally or horizontally in the matrix.

Boundary Condition(s):
2 <= N <= 100
1 <= Matrix element value <= 10^5

Input Format:
The first line contains N.
The next two lines, each contains N integer values separated by a space.

Output Format:
The first line contains the maximum sum.

Example Input/Output 1:
Input:
3
256
311

Output:
9

Example Input/Output 2:
Input:
5
13578
2 4 6 8 10

Output:
18

Example Input/Output 3:
Input:
4
9873
7649

Output:
18
Unique Alphabets to Ranges
The program must accept a string S containing only lower case
alphabets as the input. The program must find the unique
alphabets in the given string and print the alphabets as ranges in
sorted order as shown in the Example Input/Output section.

Boundary Condition(s):
1 <= Length of S <= 100

Input Format:
The first line contains S.

Output Format:
The lines contain the alphabets ranges in sorted order.

Example Input/Output 1:
Input:
fhjgipqrtsifif

Output:
f:j
p:t

Example Input/Output 2:
Input:
abbackxxyzzponm

Output:
a:c
k:k
m:p
x:z
Special Number
An integer N is a special number if N can be expressed as a sum
of an integer X and its reverse. The program must print if N is a
special number or not.

Boundary Condition(s):
1 <= N <= 10^6

Input Format:
The first line contains N.

Output Format:
The first line contains true or false.

Example Input/Output 1:
Input:
22

Output:
true

Example Input/Output 2:
Input:
121

Output:
true

Example Input/Output 3:
Input:
15

Output:
false
Escape Speed

The program must accept three floating point values as G


(gravitational constant), M(mass) and r(radius) of a planet.
The program must calculate and print the escape speed of the object
with precision up to 3 decimal places.

Formula: square root(2gm)/r)

Example Input/Output 1:
Input:
1.567 2.4783 3.4671

Output:
1.497

Example Input/Output 2:
Input:
1.9038 2.7920 4.3937

Output:
1.555
function sortSubstrings
The function/method sortSubstrings accepts two arguments str and K.
The str represents a string value whose length is always divisible by the
integer K.

The function/method sortSubstrings must split the given string into


substrings of equal length K. Then the function must sort the substrings
and return them.

Your task is to implement the function sortSubstrings so that the


program runs successfully.

The following structure is used to represent the boundedArray and is


already defined in the default code (Do not write this definition again in
your code).
typedef struct BoundedArray
{
int SIZE;
char **words;
} boundedArray;

IMPORTANT: Do not write the main() function as it is already defined.

Example Input/Output 1:
Input:
skillrack
3

Output:
ack llr ski

Example Input/Output 2:
Input:
internationalairport
4

Output:
inte iona lair port rnat
Evaluation of Simple Expression

Given an expression as a string, the program must evaluate the


expression and print the value of the expression. The allowed
operations are addition (+), subtraction (-), multiplication (*), division
(/) and power (^).
Note: Evaluation must be done from left to right direction.

Boundary Condition(s):
1 <= Length of the string <= 1000

Input Format:
The first line contains the expression.

Output Format:
The first line contains the value of the expression.

Example Input/Output 1:
Input:
2^2+3*4-2

Output:
26

Example Input/Output 2:
Input:
4+23-100

Output:
-73
Prime Sentence
The program must accept a string S representing a sentence as the input. The program must
find the sentence value of S based on the following conditions.
- All 26 alphabets from a to z or from A to Z have values are from 1 to 26 respectively.
- All 10 digits from 0 to 9 have values are from 0 to 9 respectively.
- All the other characters have the value 0.
- The sentence value is obtained by summing up all the numeric values of every single
character in S.
Then the program must print the output based on the following conditions.
- If the sentence value is a prime number, then the program must print "Prime".
- If the sentence value is a prime number after removing exactly one word in the sentence,
then the program must print "Almost Prime".
- Otherwise, the program must print "Composite".

Boundary Condition(s):
1 <= Length of S <= 1000

Input Format:
The first line contains S.

Output Format:
The first line contains a string value based on the given conditions.

Example Input/Output 1:
Input:
Lift dog

Output:
Prime

Example Input/Output 2:
Input:
Is 24 the answer?

Output:
Almost Prime

Example Input/Output 3:
Input:
Hello World!

Output:
Composite
Find and Replace

The program must accept three string values S1, S2 and S3 as the
input. The program must find all occurrences of the string S1 in the
string S3 and replace all the occurrences of the string S1 by the string
S2. Finally, the program must print the modified string S3 as the
output.
Note: String values are only in lower case
Hint: Use strcmp() in-built function

Boundary Condition(s):
1 <= Length of S1, S2 <= 20
1 <= Length of S3 <= 1000

Example Input/Output 1:
Input:
tiger lion
the tiger is a wild animal the tiger is known as the king of the jungle

Output:
the lion is a wild animal the lion is known as the king of the jungle

Example Input/Output 2:
Input:
abcd xyz
bcd abc abcd cde abcde abcd asdf bcde

Output:
bcd abc xyz cde abcde xyz asdf bcde
function findBinarySum
The function/method findBinarySum accepts two arguments N and
binValues. The binValues represents a 2-D array of characters denoting
the N binary string values.

The function/method findBinarySum must return a string containing the


binary sum of the given N binary string values.

Your task is to implement the function findBinarySum so that the


program runs successfully.

IMPORTANT: Do not write the main() function as it is already defined.

Boundary Condition(s):
2 <= N <= 100
1 <= Length of each string <= 100

Example Input/Output 1:
Input:
2
10001
11001

Output:
101010

Example Input/Output 2:
Input:
3
1000
111
100010

Output:
110001
Find the Closest Palindrome

The program must accept a number N as the input. The program must print
the closest palindromic number as the output. If there are two closest
palindromic numbers the program must print the smaller number.

Boundary Condition(s):
2 <= N <= 99999999999999

Input Format:
The first line contains the value of N.

Output Format:
The first line contains the closest palindromic number.

Example Input/Output 1:
Input:
124

Output:
121

Example Input/Output 2:
Input:
1439

Output:
1441

Input:
723891738

Expected Output:
723888327

Input:
12345678876543

Expected Output:
12345677654321
Cycle Tour
Hector has planned a cycle tour through the mountains. His tour consists of N checkpoints,
numbered from 1 to N in the order he will visit them. The ith checkpoint has a height of Hi.
A checkpoint is a peak if it is not the 1st checkpoint or the Nth checkpoint, and the height of the
checkpoint is strictly greater than the checkpoint immediately before it and the checkpoint
immediately after it.
Please help Hector find out the number of peaks.

The program must accept T test cases, where each test case contains N integers representing the
heights of the N checkpoints. For each test case, the program must print the number of peaks in
his cycle tour.

Input Format:
The first line contains T, followed by T test cases.
Each test case contains the input as below.
- The first line contains N.
- The second line contains N integers separated by a space.

Output Format:
The first T lines, each contains an integer representing the number of peaks in Hector's cycle tour.

Example Input/Output 1:
Input:
4
3
10 20 15
4
8888
5
20 80 30 80 20
3
100 30 100

Output:
1
0
2
0
Example Input/Output 2:
Input:
10
10
66 61 60 87 34 52 40 41 100 32
8
79 37 61 71 4 95 36 33
4
13 14 74 96
3
71 75 92
3
80 20 6
10
66 21 42 88 6 96 23 14 36 41
8
27 91 64 78 71 49 100 59
5
85 78 6 53 49
7
71 67 73 3 27 97 49
9
34 24 71 83 28 16 74 29 18

Output:
3
2
0
0
0
2
3
1
2
2
First Half and Second Half - String

The program must accept a string S as the input. The program must
print the alphabets of the string S which are in the first half of the
alphabets (a to m) and then the program must print the alphabets in
the string S which are in the second half of the alphabet (n to z) as the
output.
Note: The alphabets are only in lower case.

Boundary Condition(s):
1 <= Length of S <= 100

Example Input/Output 1:
Input:
electronics

Output:
elecictrons

Explantion:
The first half of the alphabets are e l e c i c
The second half of the alphabets are t r o n s
Hence the output is elecictrons

Example Input/Output 2:
Input:
keyboard

Output:
kebadyor
Print Directions - Visited Cities
The program must accept a matrix of size R*C representing R*C cities. A person
visits the cities from the top-left position and he marks the visited cities with
the integers starting from 1. The integers in the matrix represent the cities he
visited. The asterisks in the matrix represent the cities he has not visited. The
program must print the directions (N-North, S-South, E-East and W-West) in
which he visited the cities as the output.

Input Format:
The first line contains R and C separated by a space.
The next R lines, each contains C values separated by a space.

Output Format:
The first line contains a list of characters separated by a space representing the
directions in which the person visited the cities.

Example Input/Output 1:
Input:
55
12*89
* 3 6 7 10
* 4 5 * 11
* * 16 * 12
* * 15 14 13

Output:
ESSENENESSSSWWN

Example Input/Output 2:
Input:
75
1*567
234*8
****9
20 * * 11 10
19 * 13 12 *
18 15 14 * *
17 16 * * *

Output:
SEENEESSSWSWSWSWNNN
First and Last Odd Digits

Given N positive integers, the program must print the


integers if the first and last digits are odd digits.

Boundary Condition(s):
1 <= N <= 9999

Input Format:
The first line contains N.
The second line contains N integers separated by space.

Output Format:
The first line contains the specified output.

Example Input/Output 1:
Input:
4
21 33 12 15

Output:
33 15

Example Input/Output 2:
Input:
7
123 456 567 21 58 93 103

Output:
123 567 93 103
function reverseStringRetainCase
The function/method reverseStringRetainCase accepts an
argument str representing a string value that contains
multiple words.

The function/method reverseStringRetainCase must reverse


each word in the given string, but the case of the alphabets
must be retained in their positions.

Your task is to implement the function


reverseStringRetainCase so that the program runs
successfully.

IMPORTANT: Do not implement the main() function as it is


already defined.

Example Input/Output 1:
Input:
Chennai TamilNadu

Output:
Iannehc UdanlImat

Example Input/Output 2:
Input:
GoogleChrome FireFox MicrosoftEdge

Output:
EmorhcElgoog XofeRif EgdetfosoRcim
Form Greater Number by Swapping

An integer N and an array of M integers (representing the positions of the digits in N)


are passed as the input. The program must swap the digits of N at the given positions
with their adjacent digits such that the resulting number formed is greater than the
original number. A digit can be swapped with the adjacent digit to its left or the
adjacent digit to its right whichever leads to a greater number. If no greater number
can be formed by swapping the digit at given position then the digit must not be
swapped.

Note: Digits must be swapped in the order of the positions given.

Boundary Condition(s):
2 <= Number of digits in N <= 100

Input Format:
The first line contains N.
The second line contains M.
The third line contains M integers separated by space(s).

Output Format:
The first line contains an integer with its digits swapped.

Example Input/Output 1:
Input:
2343214
2
25

Output:
3243214

Example Input/Output 2:
Input:
902374890234
3
3 6 10

Output:
920378492034

Example Input/Output 2:
Input:

699731787022457192428222653599464501803523986
13
1 2 4 5 7 8 9 10 11 20 25 44 45
Employees - Working Time
The program must accept the name, in-time and out-time (in 24-hr format HH:MM) of N employees as the
input. The program must print the names of the employees in descending order based on their working time.
If two or more employees have the same working time then those employees must be printed in
chronological order based on their in-time. If two or more employees have the same working time and the
same in-time then those employees must be printed in sorted order based on their names.

Input Format:
The first line contains N.
The next N lines, each contains the name, in-time and out-time of an employee separated by a space.

Output Format:
The first N lines contain the names of the N employees based on the given conditions.

Example Input/Output 1:
Input:
7
Rajesh 08:45 16:45
Catherine 09:15 17:45
Deepa 08:00 18:00
Pravin 09:00 17:30
Jhanvi 08:45 16:45
Hector 09:00 18:00
Mambo 09:00 17:00

Output:
Deepa
Hector
Pravin
Catherine
Jhanvi
Rajesh
Mambo

Example Input/Output 2:
Input:
6
Bhuvana 16:00 23:00
Anu 11:00 23:00
Hector 09:30 16:30
John 10:15 20:15
Ramesh 09:30 16:29
Anita 09:30 16:30

Output:
Anu
John
Anita
Hector
Bhuvana
Ramesh
File - Reverse Lines
The program must accept a string S denoting the name of a text file and an integer N
as the input. The program must read the first N lines from the given file. Then the
program must print the N lines in reverse order as the output.

Note: The given file is always present in the same folder where the program executes.

Boundary Condition(s):
5 <= Length of S <= 20
1 <= N <= Number of lines in the file <= 100
1 <= Length of each line in the file <= 100

Input Format:
The first line contains S.
The second line contains N.

Output Format:
The first N lines contain the first N lines of the given file in reverse order.

Example Input/Output 1:
Input:
[Link]
5

Output:
rose
red
the
pluck
You

So the first 5 lines in the file are printed in reverse order.

Example Input/Output 2:
Input:
[Link]
2

Output:
Dog
Lion
Frequency of Alphabets in Descending Order

The program must accept a string S with lower case alphabets and print
the alphabets in the descending order of frequency of their occurrence. If
more than one alphabets are repeated for the same number of times, then
the program must print them in alphabetical order.

Boundary Condition(s):
1 <= Length of String S <= 150

Input Format:
The first line contains the string S.

Output Format:
The first line contains the alphabets sorted based on their frequency.

Example Input/Output 1:
Input:
apple

Output:
pael

Explanation:
In apple, the frequency of occurrence is a-1, p-2, l-1, e-1
So p comes first followed by a e l (thats in alphabetical order).

Example Input/Output 2:
Input:
czechoslovakia

Ouput:
acoehiklsvz
String - Shift Consonants
The program must accept a string S containing only alphabets
as the input. The program must shift the consonants to the
left by 1 position in the string S. Then the program must print
the revised string as the output.

Note: At least one consonant is always present in the string S.

Boundary Condition(s):
1 <= Length of S <= 1000

Input Format:
The first line contains S.

Output Format:
The first line contains the revised string S.

Example Input/Output 1:
Input:
Gujarat

Output:
jurataG

Example Input/Output 2:
Input:
TooL

Output:
LooT
Gold Pots Unit Digit

A series of N gold pot is found by a man. He starts picking the gold coins from
the first pot. He moves forward by the unit digit value of the count of gold coins
in the current pot and picks up the next pot. This is continued until there are no
more pots at the unit digit position from the current pot. The number of gold
coins in each pot is given as input. The program must print the total gold coins
collected.

Boundary Condition(s):
2 <= N <= 1000

Input Format:
The first line contains the value of N.
The second line contains N integers separated by space(s).

Output Format:
The first line contains the total number of gold coins collected.

Example Input/Output 1:
Input:
7
452 231 871 943 25 762 823

Output:
3089

Explanation:
Gold pots are collected in the following order 452, 871, 943 and 823.

Example Input/Output 2:
Input:
5
91 42 72 194 32

Output:
327
Matrix Layers - Repeated Sum
The program must accept an integer matrix of size N*N as the input. The program must find the
sum of integers in each layer of the matrix (from outer layer to inner layer). Then the program must
print the repeated sum among the obtained sum values. If two or more sum values are repeated,
then the program must print the first occurring sum as the output. If there is no repeated sum,
then the program must print -1 as the output.

Boundary Condition(s):
3 <= N <= 50
0 <= Matrix element value <= 1000

Input Format:
The first line contains N.
The next N lines each contain N integers separated by a space.

Output Format:
The first line contains an integer representing the repeated sum or -1 based on the given
conditions.

Example Input/Output 1:
Input:
5
23451
3 10 6 7 2
4 13 6 9 2
56533
75724

Output:
59

Example Input/Output 2:
Input:
7
76 56 96 69 12 75 81
76 69 64 95 57 62 53
84 32 64 24 18 51 10
99 8 64 22 12 88 23
52 94 28 93 43 95 97
40 1 91 8 56 84 50
76 65 20 87 97 45 80
Output:
-1

Example Input/Output 3:
Input:
8
11111111
12222221
11111121
11133121
11133111
11111111
11111111
11111111

Output:
28
Hundredth Digit Odd

Three numbers are passed as input. The program must print the number having
an odd digit in its hundredth place.

Boundary Condition(s):
1 <= N <= 999999999

Input Format:
The first line contains N.

Output Format:
The first line contains an integer.

Example Input/Output 1:
Input:
12345 400 3478

Output:
12345

Example Input/Output 2:
Input:
3439 849 567

Output:
567
Common Odd Digits - Same Position
The program must accept two integers X and Y as the input. The
program must print the integer formed by the common odd digits in
the same positions starting from the unit digit of X and Y as the
output.

Note: There will be at least one common odd digit in X and Y at the
same position.

Boundary Condition(s):
1 <= X, Y <= 10^8

Input Format:
The first line contains X.
The second line contains Y.

Output Format:
The first line contains an integer value based on the given conditions.

Example Input/Output 1:
Input:
1234599
31579

Output:
359

Example Input/Output 2:
Input:
12345
12435

Output:
15
Infinity Symbol Pattern

Given a matrix M of size N*N as input, the program must print the
output as shown in the Example Input/Output section.

Boundary Condition(s):
2 <= N <= 50

Input Format:
The first line contains the value of N.
The next N lines contain N values each separated by space.

Output Format:
The first line contains the desired output as shown in the Example
Input/Output section.

Example Input/Output 1:
Input:
3
123
567
234

Output:
164736251

Example Input/Output 2:
Input:
4
1234
5678
9 10 11 12
13 14 15 16

Output:
1 6 11 16 12 8 4 7 10 13 9 5 1
Python - C 008
Please convert the following python code to c so that the c
program executes successfully passing the test cases.

num1, num2 = map(int, input().strip().split())


K = int(input())
firstVal = bin(num1).replace("0b", "")
secondVal = bin(num2).replace("0b","")
print(int(firstVal[:K]+secondVal[len(secondVal)-K:],2))
function findMaxCost
A box is represented as:
struct Box
{
int pens;
int pencils;
int erasers;
};
The above structure is already defined in the default code (Do not write this definition again in
your code).

The function/method findMaxCost accepts two arguments N and boxes. The array 'boxes'
represents an array of type 'Box' and it contains N elements. Each element of boxes consists of
three positive integers 'pens', 'pencils' and 'erasers' representing the count of pens, pencils
and erasers in a box respectively. The cost of a pen, pencil and eraser are 10, 5 and 3
respectively.

The function/method findMaxCost must return an integer representing the maximum cost of a
box among the given N boxes.

Your task is to implement the function findMaxCost so that the program runs successfully.

IMPORTANT: Do not write the main() function as it is already defined.

Example Input/Output 1:
Input:
4
251
123
313
333

Output:
54

Example Input/Output 2:
Input:
2
10 1 1
5 10 10

Output:
130
Integers Occurring Odd Number of Times

The program must accept an integer array of size N as the input. The
program must print the integers that are occurring odd number of
times in the array as the output. If there is no integer occurring odd
number of times, then the program must print -1 as the output.

Boundary Condition(s):
3 <= N <= 100
1 <= Each integer < 100

Example Input/Output 1:
Input:
5
23345

Output:
245

Example Input/Output 2:
Input:
4
21 11 21 11

Output:
-1
Interlace Odd Even Matrix Pattern
The program must accept an integer N as the input. The program must print an integer
matrix of size N*N containing with the odd and even integers alternately among the integers
from 1 to N*N as shown in the Example Input/Output section.

Boundary Condition(s):
1 <= N <= 100

Input Format:
The first line contains N.

Output Format:
The first N lines, each contains N integers separated by a space representing the N*N
matrix.

Example Input/Output 1:
Input:
3

Output:
183
654
729

Example Input/Output 2:
Input:
4

Output:
1 16 3 14
5 12 7 10
9 8 11 6
13 4 15 2

Example Input/Output 3:
Input:
5

Output:
1 24 3 22 5
20 7 18 9 16
11 14 13 12 15
10 17 8 19 6
21 4 23 2 25
Interchange Diagonals in Matrix

The program must accept an integer matrix of size N*N as


input. The program must interchange the values in the
diagonals of the matrix. Finally, the program prints the matrix.

Boundary Condition(s):
1 <= N <= 50

Input Format:
The first line contains the value of N.
The next N lines contain N integers each separated by
space(s).

Output Format:
The first N lines contain N integers each separated by a
space.

Example Input/Output 1:
Input:
3
516
429
873

Output:
615
429
378
Camel Case Pattern Matching
The program must accept two string values S and P as the input. The string P represents a
pattern and the string S represents a string to be matched with the pattern P. The program
must print YES if the string S matches the pattern P. Else the program must print NO as the
output. The string S matches the pattern P if and only if we can insert lower case alphabets
in P so that it is equal to the string S.

Boundary Condition(s):
1 <= Length of S, P <= 1000

Input Format:
The first line contains S.
The second line contains P.

Output Format:
The first line contains either YES or NO.

Example Input/Output 1:
Input:
FootBall
FoBa

Output:
YES

Example Input/Output 2:
Input:
GreedyAlgorithm
GAl

Output:
YES

Example Input/Output 3:
Input:
MondayToTuesday
MoTo

Output:
NO

Example Input/Output 4:
Input:
NorthEastSouth
NooES

Output:
NO
Integer Compression - Right to Left
The program must accept an integer N as the input. The program must
compress the integer by concatenating the sum of every two digits from right
to left in N until the integer becomes a single-digit integer. The program must
print the integer values obtained during the compression process(including N)
as the output.

Boundary Condition(s):
0 <= N <= 10^8

Input Format:
The first line contains N.

Output Format:
The lines contain the integer values based on the given conditions.

Example Input/Output 1:
Input:
2345677

Output:
2345677
271114
925
97
16
7

Example Input/Output 2:
Input:
1234566

Output:
1234566
15912
1143
27
9
Inverted V Pattern

The program must accept the values of string S1 and S2 as input. The program must print the
desired pattern as shown in the Example Input/Output section.

Boundary Condition(s):
2 <= Length of S1, S2 <= 100

Input Format:
The first line contains the value of string S1.
The second line contains the value of string S2.

Output Format:
The list of lines contain the desired pattern as shown in the Example Input/Output section.

Example Input/Output 1:
Input:
orange
energy

Output:
-----e
----g-n
---n---e
--a-----r
-r-------g
o---------y

Example Input/Output 2:
Input:
apple
orange

Output:
-1

Example Input/Output 3:
Input:
neuro
lemon

Output:
----n
---o-e
--m---u
-e-----r
l-------o
function getConsecutiveVowels
The function/method getConsecutiveVowels accepts an argument str representing a
string value which contains only alphabets.

The function/method getConsecutiveVowels must return an array of string values


representing the consecutive vowels in the given string str. If there is no vowel in the
string, then the function must return an array of size 1 with the string value "-1".

Your task is to implement the function getConsecutiveVowels so that it passes all the test
cases.

The following structure is used to represent the boundedArray and is already defined in
the default code (Do not write this definition again in your code).
typedef struct BoundedArray
{
int SIZE;
char **vowels;
} boundedArray;

IMPORTANT: Do not write the main() function as it is already defined.

Example Input/Output 1:
Input:
eagle

Output:
ea
e

Example Input/Output 2:
Input:
AbcdEIOfghIOUA

Output:
A
EIO
IOUA

Example Input/Output 3:
Input:
jklmn

Output:
-1
IPv4 Address Validity

Given an IPv4 address as a string, check if the address is valid. Print


Valid if the address is valid else print Invalid. IPv4 address has 4
blocks of 8 bit (unsigned) numbers ranging from 0 to 255 separated
by a . (dot).

Boundary Condition(s):
1 <= Length of address <= 50

Input Format:
The first line contains the IP address.

Output Format:
The first line contains Valid or Invalid.

Example Input/Output 1:
Input:
[Link]

Output:
Valid

Example Input/Output 2:
Input:
[Link].12

Output:
Invalid
Append Alphabet - Surrounding Integers

The program must accept a matrix of size R*C containing integers and alphabets as the input.
For each occurrence of the alphabet in the matrix, the program must append
the alphabet to the surrounding integers of the alphabet. Then the program must print the
revised matrix as the output.

Note: In the given matrix, there are no common integers around two or more alphabets.
Boundary Condition(s):
2 <= R, C <= 50
1 <= Each integer value in the matrix <= 1000

Input Format:
The first line contains R and C separated by a space.
The next R lines, each contains C elements of the matrix separated by a space.

Output Format:
The first R lines contain the revised matrix.

Example Input/Output 1:
Input:
45
52224
7523b
8a559
93856
Output:
5 2 2 2b 4b
7a 5a 2a 3b b8
a a 5a 5b 9b
9a 3a 8a 5 6

Example Input/Output 2:
Input:
55
86 77 45 57 82
13 A 10 86 70
32 74 72 27 C
28 79 12 43 90
15 B 13 15 37

Output:
86A 77A 45A 57 82
13A A 10A 86C 70C
32A 74A 72A 27C C
28B 79B 12B 43C 90C
15B B 13B 15 37
Largest Even Number

The program must accept two numbers N1 and N2 as the input and it
must print the largest possible even number with non-zero unit digit
as the output containing all the digits from both the numbers. If an
even number with non-zero unit digit cannot be formed using the
digits from the two numbers, the program must print -1 as the
output.
Note: The last digit must not be zero.

Boundary Condition(s):
1 <= N1, N2 <= 99999999

Input Format:
The first line contains the value of N1 and N2 separated by space.

Output Format:
The first line contains the largest possible even number.

Example Input/Output 1:
Input:
784201 86976

Output:
98877664102
Digits Asterisks Pattern
The program must accept a string S containing only digits as the input. The program must
print the digits in the string S based on the following conditions.
- The digits of the same value must be printed on the same line.
- The values of the digits must be printed in the order of their occurrence.
- The empty spaces in each row must be printed as asterisks.

Input Format:
The first line contains S.

Output Format:
The lines contain the digits and asterisks based on the given conditions.

Example Input/Output 1:
Input:
1225644789964

Output:
1**
22*
5**
66*
444
7**
8**
99*

Example:
Here S = 1225644789964.
1 occurs one time.
2 occurs two times.
5 occurs one time.
6 occurs two times.
4 occurs three times.
7 occurs one time.
8 occurs one time.
9 occurs two times.

Example Input/Output 2:
Input:
624655622653

Output:
6666
222*
4***
555*
3***
7
Largest Integer in Each Row

Given a matrix M of size R*C, the program must print the largest integer
in each row.

Boundary Condition(s):
2 < R, C < 50

Input Format:
The first line contains R and C separated by space.
The next R lines contain C values each separated by a space.

Output Format:
The first R lines contain the largest integer in each row.
Example Input/Output 1:
Input:
33
123
465
789

Output:
3
6
9

Example Input/Output 2:
Input:
34
12 23 34 45
21 3 55 67
2 45 56 12
Output:
45
67
56
Move to Beginning - Operations Count
The program must accept a string S and two integers X, Y as the input.
The program must perform the following two operations alternately on
the given string S until the string becomes the original string.
- Move the last X characters to the beginning.
- Move the last Y characters to the beginning.
Finally, the program must print the number of operations performed on
the given string S as the output.

Boundary Condition(s):
1 <= Length of S <= 100
1 <= X, Y <= Length of S

Input Format:
The first line contains S.
The second line contains X and Y separated by a space.

Output Format:
The first line contains an integer representing the number of operations
performed on the given string S.

Example Input/Output 1:
Input:
high
12

Output:
3

Example Input/Output 2:
Input:
SkillRack
31

Output:
13
function sortBasedOnDigits
The function/method sortBasedOnDigits accepts two arguments
SIZE and arr. The integer SIZE represents the size of the integer
array arr.

The function/method sortBasedOnDigits must sort the integers


in the given array based on digits starting from the most
significant digit.

IMPORTANT: Do not write the main() function as it is already


defined.

Example Input/Output 1:
Input:
6
200 2 22 32 3 4

Output:
2 200 22 3 32 4

Example Input/Output 2:
Input:
5
124 1201 204 230 104

Output:
104 1201 124 204 230
Largest Unit Digit Number

Two integers X and Y are given as input. The program must


print the integer with largest unit digit. If the unit digits are
equal, then print the larger integer.

Boundary Condition(s):
1 <= X, Y <= 1000000

Input Format:
The first line contains X and Y separated by a space.

Output Format:
The first line contains an integer value.

Example Input/Output 1:
Input:
51 23

Output:
23

Example Input/Output 2:
Input:
77 87

Output:
87
Frequency Shift Encryption
The program must accept a string S containing only lower case
alphabets as the input. The program must encrypt the given string
based on the following conditions.
- For each alphabet CH in the string S, the program must modify the
alphabet based on a shift value.
- The value of the shift is determined by the count of occurrences of
CH before the position of CH in the original string S.
- If the modified value of the alphabet goes beyond 'z', the shift wraps
around to the beginning (i.e., If the alphabet is 'z' and the shift value is
2, then the modified value is 'b').
Finally, the program must print the encrypted string as the output.

Boundary Condition(s):
2 <= Length of S <= 1000

Input Format:
The first line contains S.

Output Format:
The first line contains the encrypted string.

Example Input/Output 1:
Input:
currentaffairs

Output:
cursentafgbits

Example Input/Output 2:
Input:
abyzabyzabyz

Output:
abyzbczacdab
Last Repeating Integer

N integers are passed as the input. The program must print the last
repeating integer among the N integers.

Boundary Condition(s):
1 <= N, value of integers <= 1000

Input Format:
The first line contains the integer N.
The second line contains N integers separated by space(s).

Output Format:
The first line contains the last repeating integer.

Example Input/Output 1:
Input:
6
121527

Output:
2

Example Input/Output 2:
Input:
7
12 34 34 34 12 45 67

Output:
12
Split Integers - Even Number of Digits
The program must accept an integer N as the input. The program must
split the integer into two equal halves if the number of digits in the integer
is even. Then the program must repeat the process on the resulting
integers till there is no integer with an even number of digits. The leading
zeroes must not be considered after each split operation. Finally, the
program must print the resulting integers in sorted order.

Boundary Condition(s):
1 <= N <= 10^18

Input Format:
The first line contains N.

Output Format:
The first line contains the integer values based on the given conditions.

Example Input/Output 1:
Input:
1024

Output:
0124

Example Input/Output 2:
Input:
50000006

Output:
0056

Example Input/Output 3:
Input:
923456

Output:
456 923
Train - Passengers Waiting Time
The program must accept the departure time of a train (in 24-hr format HH:MM) at a station S as
the input. The name and the arrival time (in 24-hr format HH:MM) of N persons to the station S are
also passed as the input to the program. The program must print the name of each person and
his/her waiting time (in minutes) at the station S as the output. If a person arrives at the station
after the train departs, then the program must print the name of the person followed by -1 as the
output.

Input Format:
The first line contains the departure of a train.
The second line contains N.
The next N lines, each contains the name of a person and the arrival time to the station separated
by a space.

Output Format:
The first N lines, each contains the name of a person followed by his/her waiting time at the
station S or -1 based on the given conditions.

Example Input/Output 1: Example Input/Output 2:


Input: Input:
10:53 16:25
7 6
Rajesh 09:15 Ramesh 16:30
Catherine 10:05 Jhanvi 16:11
Anu 10:17 Bhuvana 16:25
Pravin 09:52 Kavin 16:24
Deepa 10:53 Anu 16:18
Mambo 10:33 Hector 16:29
Anita 11:00
Output:
Output: Ramesh -1
Rajesh 98 Jhanvi 14
Catherine 48 Bhuvana -1
Anu 36 Kavin 1
Pravin 61 Anu 7
Deepa -1 Hector -1
Mambo 20
Anita -1
Least Occurring Digits

A series of N integers is passed as input. The program must print the


least occurring digit(s) in series of integers in ascending order.

Boundary Condition(s):
1 <= N <= 1000

Input Format:
The first line contains the series of integers separated by space(s).

Output Format:
The first line contains the least repeated digits in ascending order
separated by a space.

Example Input/Output 1:
Input:
35 81 78 84 53

Output:
147

Example Input/Output 2:
Input:
12 21 68 55 71 29 60 879

Output:
0
Shadow Sentences or Not
The program must accept two string values S1 and S2 representing two sentences as the
input. The program must print YES if the two sentences are shadows of each other. Else the
program must print NO as the output. If two sentences are shadows of each other, then the
following conditions must be true.
- The number of words in both sentences must be equal.
- The length of each word that occurs in the same position in both sentences must be equal,
but the corresponding words must not share any common characters.

Boundary Condition(s):
1 <= Length of S1, S2 <= 1000

Input Format:
The first line contains S1.
The second line contains S2.

Output Format:
The first line contains YES or NO.

Example Input/Output 1:
Input:
four ten history
tent was damaged

Output:
YES

Example Input/Output 2:
Input:
hat mat tiger elephant
run gun water keyboard

Output:
NO

Example Input/Output 3:
Input:
mobile camera
army ant nano

Output:
NO
Left Right Odd Count

An array of N integers is given as the input to the program. For each


integer the program must print the integer if the count of odd
integers on the left side is equal to the count of odd integers on the
right side. Else the program must print -1 for that integer.

Boundary Condition(s):
1 <= N <= 10^5

Input Format:
The first line contains the value of N.
The second line contains N integers separated by space(s).

Output Format:
The first line contains N integers separated by a space.

Example Input/Output 1:
Input:
6
134857

Output:
-1 -1 4 8 -1 -1
Longest Continuous Alphabets Sequence

Given a string S as input, the program must print the longest


continuous alphabets sequence in the string.

Boundary Condition(s):
1 <= Length of S <= 1000

Input Format:
The first line contains the string S.

Output Format:
The first line contains the longest continuous alphabets sequence in
the string.

Example Input/Output 1:
Input:
abchyzabs

Output:
yzab

Example Input/Output 2:
Input:
cdefghijklmnopqrst

Output:
cdefghijklmnopqrst
Longest Series Surrounded by M

An array of N integers and an integer M are passed as input. The


program must print the longest series of integers surrounded by M
on its both ends. The series must not contain the integer M. If more
than one longest such series are found print the last occurring series.

Boundary Condition(s):
3 <= N <= 1000
1 <= M <= 999999999

Input Format:
The first line contains N and M separated by space(s).
The second line contains N integers separated by space(s).

Output Format:
The first line contains the longest series of integers separated by a
space.

Example Input/Output 1:
Input:
72
45 2 21 534 2 45 2

Output:
21 534

Example Input/Output 2:
Input:
10 23
23 76 23 129 34 12 23 45 67 23

Output:
129 34 12
Longest Substring Without Vowels

Given a string S as input, the program must print the longest


substring without any vowels. If there are no such substring (all
characters are vowels) then print -1. If the substrings are of same
length print the first substring.

Boundary Condition(s):
2 <= Length of S <= 100

Input Format:
The first line contains the string S without any space.

Output Format:
The first line contains the longest substring without any vowels else
-1.

Example Input/Output 1:
Input:
awkxqdtpetsqwjh

Output:
wkxqdtp
Longest Word

The program must accept a string S as the input. The program print the
longest word from the string S as the output.
If two or more longest words are of same length then consider the first one.

Boundary Condition(s):
1 <= Length of S <= 1000

Example Input/Output 1:
Input:
Good Morning

Output:
Morning

Explanation:
The length of the word "Good" is 4 and the length of the "Morning" is 7
Hence Morning is printed as the output.

Example Input/Output 2:
Input:
good time

Output:
good
Lucky Draw Winner

N players(with jersey numbered from 1 to N) sat in a line to play a


game. A number K is randomly drawn out from a box. On each draw,
the player at the position K is eliminated from the game. Print the
jersey number of the winner after N-1 draws.
Note: After each elimination, the positions are filled by the person
next to it and hence there is no gap between players after
elimination.

Boundary Condition(s):
2 <= N <= 50

Input Format:
The first line contains the value of N.
The second line contain N values separated by space(s).
The third line contain N-1 values separated by space(s).

Output Format:
The first line contains the jersey number of the winner.

Example Input/Output 1:
Input:
6
100 200 300 400 500 600
14231

Output:
400
Matrix Non-Border Elements Sum

An integer matrix of size RxC is passed as the input to the program.


The program must print the sum of elements which are not present in
the border of the matrix.

Boundary Condition(s):
2 <= R,C <= 50

Input Format:
The first line contains the value of R and C separated by space(s).
The next R lines contain C integers each separated by space.

Output Format:
The first line contains the sum of elements which are not present
along the border.

Example Input/Output 1:
Input:
44
18 5 5 21
23 24 1 25
8 5 15 17
23 4 29 2

Output:
45
Matrix Sort Corner Elements Clock-wise

An integer matrix of size R*C is passed as input. The program must sort the
elements at the corner position of the matrix in clock-wise direction and print
the matrix.

Boundary Condition(s):
1 <= R, C <= 1000

Input Format:
The first line contains the value of R and C separated by space(s).
The next R lines contain C elements each separated by space(s).

Output Format:
The first R lines contain C elements each separated by a space with corner
elements sorted in clock-wise direction.

Example Input/Output 1:
Input:
33
927
456
381

Output:
123
456
987

Example Input/Output 2:
Input:
43
924 450 994
58 146 589
526 548 407
471 145 779

Output:
471 450 779
58 146 589
526 548 407
994 145 924
Matrix Top View

A character matrix of size R*C is passed as input. The program must print the
first alphabet in each column.
Note: At least one alphabet will be present in a column.

Boundary Condition(s):
1 <= R <= 100
1 <= C <= 100

Input Format:
The first line contains the value of R and C.
Next lines contain the values in the R*C matrix with each value separated by
one space.

Output Format:
The first line contains the top view of the matrix.

Example Input/Output 1:
Input:
36
m--t-r
a-saed
iand-a

Output:
master

Example Input/Output 2:

Input:
49
s--l-r--k
-k--l-a--
--i------
-------c-

Output:
skillrack
Maximum of Odd and Even Digit Count

An integer N is passed as input. The program must print the odd digit
count if odd digit count is greater than even digit count. Else the
program must print the even digit count.

Boundary Condition(s):
1 <= N <= 999999999

Input Format:
The first line contains N.

Output Format:
The first line contains an integer.

Example Input/Output 1:
Input:
12345

Output:
3

Example Input/Output 2:
Input:
8982374

Output:
4
Minimum Spring Hops

A series of springs are represented as an array of size N. Each value in array defines the power of
spring to push the object forward. A starting spring value M is passed as input. Find the minimum
number of hops needed for the object to reach the last spring. If last spring cannot be reached
print -1.

Boundary Condition(s):
2 <= N <= 1000
1 <= M <= 1000

Input Format:
The first line contains the value of N and M separated by space(s).
The second line contains N integers separated by space(s).

Output Format:
The first line contains the minimum number of hops to reach the last spring.

Example Input/Output 1:
Input:
93
532113134

Output:
1

Explanation:
Starting value 3 occurs thrice. Traversing from 3 at 6th position will be minimal to reach the last
spring (3->4).

Example Input/Output 2:
Input:
10 5
5321837316

Output:
3

Explanation:
There is only one starting value 5. The number of hops needed is 3 (5->3->1->6).
Mirror Pattern Matrix

An integer N is passed as input. The program must print the


pattern as given in the Example Input/Output section.

Boundary Condition(s):
1 <= N <= 100

Input Format:
The first line contains N.

Output Format:
The first N lines contain the specified output.

Example Input/Output 1:
Input:
3

Output:
12321
45654
78987

Example Input/Output 2:
Input:
4

Output:
1234321
5678765
9 10 11 12 11 10 9
13 14 15 16 15 14 13
N Equal Strings

The program must accept a string S and an integer N as the input. The
program must print N equal parts of the string S if the string S can be
divided into N equal parts. Else the program must print -1 as the
output.

Boundary Condition(s):
2 <= Length of S <= 1000
2 <= N <= Length of S

Example Input/Output 1:
Input:
whiteblackgreen 3

Output:
white black green

Explanation:
Divide the string whiteblackgreen into 3 equal parts as white black
green
Hence the output is white black green

Example Input/Output 2:
Input:
pencilrubber 5

Output:
-1
N Integers Unit Digit Multiplication

The program must accept N integers as input. The program must


print the N integers multiplied by the unit digit of previous integer.
The first integer has no previous integer, so it is multiplied by the unit
digit of Nth integer.

Boundary Condition(s):
2 <= N <= 100

Input Format:
The first line contains the N.
The second line contains the N integers separated by space(s).

Output Format:
The first line contains the N integers.

Example Input/Output 1:
Input:
5
12 34 11 15 16

Output:
72 68 44 15 80

Example Input/Output 2:
Input:
3
123 145 16

Output:
738 435 80
Next Number Same Unit Digit

An array of N integers are given as input. The program must print the
integers only if the unit digit of the current integer and the unit digit
of the next integer are same.

Boundary Condition(s):
2 <= N <= 1000

Input Format:
The first line contains the value of N.
The second line contains N integers separated by space(s).

Output Format:
The first line contains integers separated by a space.

Example Input/Output 1:
Input:
6
12 834 94 485 285 905

Output:
834 485 285

Example Input/Output 2:
Input:
6
91 41 74 192 32 45

Output:
91 192
Next Palindromic Number

An integer N is passed as input. The program must print the


immediate next palindromic number of N.

Boundary Condition(s):
1 <= N <= 999999999

Input Format:
The first line contains N.

Output Format:
The first line contains the immediate next palindromic
number of N.

Example Input/Output 1:989989

Input:
119

Output:
121

Example Input/Output 2:
Input:
1111

Output:
1221
Nth Repeating Character - String

A string S is passed as the input to the program. The program must print
the Nth repeating character C in the string S. The repeating characters
are considered in their order of occurrence from the beginning of the
string S. If no such Nth repeating character is present the program must
print -1 as the output.

Input Format:
The first line contains the value of S.

Output Format:
The first line contains the value of C.

Boundary Conditions:
2 <= Length of S <= 1000

Example Input/Output 1:
Input:
abcdaeaedbapple
3

Output:
d

Example Input/Output 2:
Input:
desktoppublishing
3

Output:
i
Odd Border Elements

Given an integer N value which is the size of a square matrix, the


program must print odd integers present in the border of the
square matrix.

Boundary Condition(s):
1 <= N <= 100

Input Format:
The first line contains the value of N.
The next N lines contain the matrix.

Output Format:
The first line contains the odd integers present in the border of
the matrix each separated by a space.

Example Input/Output 1:
Input:
3
45 87 190
74 21 35
89 45 42

Output:
45 87 35 89 45

Example Input/Output 2:
Input:
4
56 78 12 30
90 56 27 29
65 278 25 9
37 81 77 20

Output:
29 65 9 37 81 77
First D Surrounding Digits SumThe program must accept an integer matrix of size
R*C containing only digits from 1 to 8 as the input.
For each digit D in the matrix, the program must print the sum of the first D
surrounding digits as the output.
If the number of surrounding digits of D is less than D, then the program must
print the sum of all the surrounding digits of D.
The order of surrounding digits is given below.
top-left, top, top-right, right, bottom-right, bottom, bottom-left and left.

Boundary Condition(s):
2 <= R, C <= 50

Input Format:
The first line contains R and C separated by a space.
The next R lines, each contains C integers separated by a space.

Output Format:
The first R lines, each contains C integers separated by a space representing the
sum of surrounding digits based on the given conditions.

Example
Input/Output 1:
input:
33
752
383
241

Output:
16 23 11
20 27 8
11 15 8

Hence the output is


16 23 11
20 27 8
11 15 8

Example Input/Output 2:

Input:
34
3443
1714
3552

Output:
12 13 15 9
3 25 4 14
13 17 19 5
Pattern Printing - Diamond Numbers

Given an integer N as the input, print the pattern as given in the


Example Input/Output section.

Input Format:
The first line contains N.

Output Format:
2N-1 lines containing the desired pattern.

Boundary Conditions:
2 <= N <= 50

Example Input/Output 1:
Input:
3

Output:
00100
02080
30007
04060
00500

Example Input/Output 2:
Input:
5

Output:
000010000
0 0 0 2 0 16 0 0 0
0 0 3 0 0 0 15 0 0
0 4 0 0 0 0 0 14 0
5 0 0 0 0 0 0 0 13
0 6 0 0 0 0 0 12 0
0 0 7 0 0 0 11 0 0
0 0 0 8 0 10 0 0 0
000090000
function getArrayFromString
The function/method getArrayFromString accepts two arguments str
and K representing a string value and an integer value respectively.
The string str contains only [Link] function/method
getArrayFromString must form K-digit integers from the given string
based on the following conditions.- For every K digits in the given
string, the function must form an integer.
If there are leading zeroes in the K digits, then the function must
move those leading zeroes to the end and form the [Link] the
function must return an array containing those K-digit integers.
Note:- The length of the string is always divisible by K.
- There will be at least one nonzero digit in every K digits.

Your task is to implement the function getArrayFromString so that it


passes all test cases.

The following structure is used to represent the boundedArray and is


already defined in the default code (Do not write this definition again
in your code).
typedef struct BoundedArray
{
int SIZE;
int *arr;
} boundedArray;

IMPORTANT: Do not write the main() function as it is already defined.


Example Input/Output 1:

Input: 121021562005468058 3
Output:121 210 562 500 468 580

Example Input/Output 2:

Input:50000004 4
Output:5000 4000
Random Number Game

In a game, there is a machine that generates a random number when a player presses
a button. Initially, a player puts X rupees in the machine and starts the game.
He can press the button N times. If he gets a random number equal to the amount in
the machine, then the amount gets doubled. After pressing the button N times, he
can collect the amount from the machine if the amount is doubled at least once.
Otherwise, he will lose the amount. The program must accept N integers representing
the N random numbers and the value of X as the input. The program must print the
final amount the player gets as the output.

Boundary Condition(s):
1 <= N <= 100
1 <= Each random number, X <= 10^6
Input Format:

The first line contains N.


The second line contains N integers separated by a space representing the N random
numbers.
The third line contains X.

Output Format:
The first line contains an integer representing the final amount the player gets.

Example Input/Output 1:

Input:
7
10 2 4 11 15 12 8
2

Output:
16

Example Input/Output 2:
Input:
6
15 20 50 4 6 10
5

Output:
0
In a straight line, a robot is placed at position 0 (i.e., at the time t=0, the robot is placed at 0).
The robot receives N moving commands. Each command contains two integers T and X, where
T represents the time in which the robot receives the command and X represents the
destination point on the straight line.
If the robot receives a command, it starts moving towards the destination point X with the
speed of 1 unit per second and it stops when it reaches the destination point. The robot
ignores the commands when it is moving.
The N commands are passed as the input to the program.

The program must print the number of commands ignored by the robot as the output.
Then the program must print the position of the robot after processing the N commands.

Note:
All commands are always given in chronological order based on the time T.

Input Format:

The first line contains N.


The next N lines, each contains two integers separated by a space representing the values of T
and X.

Output Format:
The first line contains an integer representing the number of commands ignored by the robot.
The second line contains an integer representing the final position of the robot.

Example
Input/Output 1:

Input:
3
15
24
61
Output:
1
1

Example Input/Output 2:
Input:6
1 -5
24
35
40
76
10 1

Output:
4
6
Pattern Printing - Mirror Image with Hyphens

Accept a number N as the input. The program must print the mirror image
pattern as the shown in the Example Input/Output section.

Boundary Condition(s):
3 <= N <= 30

Input Format:
The first line contains the value of N.

Output Format:
The first N lines contain the mirror image pattern.

Example Input/Output 1:
Input:
5

Output:
55555-55555
4444---4444
333-----333
22-------22
1---------1

Example Input/output 2:
Input:
4

Output:
4444-4444
333---333
22-----22
1-------1
Remove Unit Digits - Previous & Next
The program must accept a list of N integers and an integer T as the input.
The program must remove T unit digits in the given list of integers based on the
following conditions.
- The program must start removing the unit digits from the 1st integer.
- If the removed unit digit is even, then the program must remove the unit digit of
the next integer. Else the program must remove the unit digit of the previous
integer.
- Similarly, the program must remove T unit digits in the given list of integers.
- Once all the digits in an integer are removed, then the integer itself must be
removed from the given list.
- Consider the given list of integers in circular fashion when finding the previous
and next integers.
Finally, the program must print the sum S of the modified integers in the list as the
output.
If all integers are removed, then the program must print -1 as the output.

Input Format:
The first line contains N.
The second line contains N integers separated by a space.
The third line contains T.

Output Format:

The first line contains S or -1.

Example Input/Output 1:
Input:
4
87369 4012 22312 39845
6
Output:
3903

Example Input/Output 2:

Input:
4
22 44 33 55
7
Output:
5

Example Input/Output 3:

Input:
3
123 456 789
9
Output:
-1
Pattern Printing - Start Number

Given an integer N as the input and a start integer S, print the pattern as given in the Example
Input/Output section.

Input Format:
The first line contains S and N, each separated by a space.

Output Format:
2N lines containing the desired pattern.

Boundary Conditions:
2 <= N <= 50
1 <= S <= 20
Example Input/Output 1:
Input:
34

Output:
3
44
555
6666
6666
555
44
3
Example Input/Output 2:
Input:
79
Output:
7
88
999
10 10 10 10
11 11 11 11 11
12 12 12 12 12 12
13 13 13 13 13 13 13
14 14 14 14 14 14 14 14
15 15 15 15 15 15 15 15 15
15 15 15 15 15 15 15 15 15
14 14 14 14 14 14 14 14
13 13 13 13 13 13 13
12 12 12 12 12 12
11 11 11 11 11
10 10 10 10
999
88
7
function removeReversedWords

The function/method removeReversedWords accepts two


arguments str1 and str2 representing two string values.
The string str1 contains multiple words separated by a space.
The string str2 contains exactly one word.
The function/method removeReversedWords must remove
all the occurrences of the word str2 and its reverse in the
string str1.
Then the function must return the revised string as a new
string. If the string becomes empty, then the function must
return -1 as a string.
Your task is to implement the function
removeReversedWords so that the program runs
successfully.

IMPORTANT: Do not write the main() function as it is already


defined.

Example
Input/Output 1:

Input:
nightingale lion tiger mosquito noil cockroach lion fox panda
lizard
lion

Output:
nightingale tiger mosquito cockroach fox panda lizard

Example
Input/Output 2:

Input:
monkey monkey yeknom monkey yeknom
yeknom

Output:
-1
Power of 2 or -2

Given an integer N, the program must determine if it is a power of 2


or -2. If N is a power of 2 or -2, the program must print yes. Else the
program must print no.

Boundary Condition(s):
-10^17 <= N <= 10^17

Input Format:
The first line contains the value of N.

Output Format:
The first line contains either yes or no

Example Input/Output 1:
Input:
32

Output:
yes

Example Input/Output 2:
Input:
90

Output:
no
There are N empty buckets in a row. Every second, a certain number of balls fill
each bucket.
The maximum capacity of each bucket is K. If the number of balls exceeds the
maximum capacity of a bucket, the remaining balls will overflow.
When a bucket is full or overflowing, a boy collects the balls from the bucket and
empties the bucket again.
The program must accept an integer matrix of size T*N representing the number of
balls that fall into N buckets in T seconds and the value of K as the input.
The program must print the number of balls he can collect as the output.
At T = 1, the balls in the last row of the matrix will fall into the N buckets.
At T = 2, the balls in the last but one row of the matrix will fall into the N buckets
and so on.

Input Format:

The first line contains T and N separated by a space.


The next T lines, each containing N integers separated by a space.
The T+2nd line contains K.

Output Format:
The first line contains the number of balls the boy can collect.

Example Input/Output 1:

Input:
55
11514
54324
34322
51413
14222
8

Output:
48

Example

Input/Output 2:
Input:
67
4648625
7621168
2265618
4366779
5991713
9812752
22

Output:
154
String - Remove Minimum Characters
The program must accept a string S as the input. The program must print the minimum
number of characters to be removed from the string S so that the length of the revised
string must be even(possibly 0) also every two consecutive characters(non-overlapping)
must be different.

Boundary Condition(s):
2 <= Length of S <= 1000

Input Format:
The first line contains S.

Output Format:
The first line contains an integer value representing the minimum number of characters to
be removed from S.

Example Input/Output 1:

Input:
coffee

Output:
2

Example Input/Output 2:

Input:
dddeeeeddd
Output:
6

Example Input/Output 3:
Input:
grapes
Output:
0
Example Input/Output 4:

Input:
aabbaaabbbc

Output:
3
Previous Number Same Unit Digit

An array of N integers are given as input. The program must print the
integers only if the unit digit of the current integer and unit digit of
the previous integer are same.

Boundary Condition(s):
2 <= N <= 1000

Input Format:
The first line contains the value of N.
The second line contains N integers separated by space(s).

Output Format:
The first line contains integers separated by a space.

Example Input/Output 1:
Input:
6
12 834 94 485 285 905

Output:
94 285 905

Example Input/Output 2:
Input:
6
91 41 74 192 32 45

Output:
41 32
First Non-Repeated Submatrix
The program must accept a character matrix of size R*C and an integer K as the input. The
values of R and C are always divisible by K. The program must print the first non-repeated
K*K submatrix in the given matrix as the output. If there is no such submatrix, then the
program must print -1 as the output.

Boundary Condition(s):
4 <= R, C <= 50
2 <= K <= 25

Input Format:
The first line contains R and C separated by a space.
The next R lines, each contains C characters separated by a space.
The R+2nd line contains K.

Output Format:
The first K lines contain the first non-repeated K*K submatrix in the given matrix or the
first line contains -1.

Example
Input/Output 1:
Input:
69
abclmnabc
defpqrdef
ghixzyghi
cbacbanml
fedfedrqp
ihgihgyzx
3
Output:
lmn
pqr
xzy

Example
Input/Output 2:
Input:
44
abcd
efgh
cdab
ghef
2
Output:
-1
Collect Gold Coins - Instructions

In a room, the RxC boxes are arranged as a matrix where each box contains gold coins. A
set of instructions are given to a boy to pick the boxes in the room. The initial position of the
boy is (1, 1). He can move around the room based on the following instructions.
- If it is N, then he can move 1 step towards North.
- If it is E, then he can move 1 step towards East.
- If it is W, then he can move 1 step towards West.
- If it is S, then he can move 1 step towards South.
The boy is allowed to take gold coins from the room based on the following conditions.
- He must take all the coins out of the box when he picks a box the first time.
- Whenever he picks up the same box a second time or more, he must put 1 gold coin in
that box using the same gold coins that he collected from the same box. If there are no coins
to put in the box when picking it multiple times, then he just ignores the box.

The program must accept an integer matrix of size RxC representing the RxC boxes and a
string S representing the set of instructions as the input. The program must print the total
number of gold coins he can collect as the output.

Note:
The given instructions are always valid (i.e., there is no instruction that will take him out of
the room).

Input Format:
The first line contains R and C separated by a space.
The next R lines, each contains C integers separated by a space.
The R+2nd line contains S.
Output Format:
The first line contains an integer representing the total number of gold coins he can collect.

Example Input/Output 1:
Input:
33
546
251
123
EESWNW
Output:
19
Example Input/Output 2:
Input:
33
546
251
123
EESWNESSNN
Output:20
Explanation:
Initially, he collects 5 gold coins from the box (1, 1).
E -> He collects 4 gold coins from the box (1, 2).
E -> He collects 6 gold coins from the box (1, 3).
S -> He collects 1 gold coin from the box (2, 3).
W -> He collects 5 gold coins from the box (2, 2).
N -> He puts 1 gold coin in the box (1, 2).
E -> He puts 1 gold coin in the box (1, 3).
S -> He puts 1 gold coin in the box (2, 3).
S -> He collects 3 gold coins from the box (3, 3).
N -> He just ignores the box (2, 3) as there are no coins to put in that box.
N -> He puts 1 gold coin in the box (1, 3).
The total gold coins = 5 + 4 + 6 + 1 + 5 - 1 - 1 - 1 + 3 + 0 - 1 = 20.
So 20 is printed as the output.
Print A To B, C To B And B To D

Given four integers A, B, C and D as input, the program must print the
numbers from A to B in the first line, C to B in the second line and B
to D in the third line.

Boundary Condition(s):
1 <= A, B, C, D <= 1000

Input Format:
The first line contains the values of A, B, C and D separated by
space(s).

Output Format:
The first line contains values from A to B separated by space.
The second line contains values from C to B separated by space.
The third line contains values from B to D separated by space.

Example Input/Output 1:
Input:
1234

Output:
12
32
234

Example Input/Output 2:
Input:
28 35 47 58

Output:
28 29 30 31 32 33 34 35
47 46 45 44 43 42 41 40 39 38 37 36 35
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
58
function removeRowsWithSameValue
The function/method removeRowsWithSameValue accepts three arguments - R, C and
matrix. The first two arguments R and C represent the size of an integer matrix. The third
argument matrix represents a pointer to the integer matrix.

The function/method removeRowsWithSameValue must remove the rows having the same
value. Then the function must return the revised matrix. If all the rows of the matrix are
removed, then the function must return a matrix of size 1*1 with the value -1.

Your task is to fill in the missing lines of code to implement the function
removeRowsWithSameValue so that it passes all the test cases.

The following structure is used to represent the boundedArray and is already defined in the
default code (Do not write this definition again in your code).

typedef struct BoundedArray


{
int R, C;
int **matrix;
} boundedArray;

IMPORTANT: Do not write the main() function as it is already defined.

Example Input/Output 1:
Input:
54
10 20 30 10
50 50 50 50
55 55 66 55
40 30 20 10
55 55 55 55

Output:
10 20 30 10
55 55 66 55
40 30 20 10

Example Input/Output 2:
Input:
33
444
888
222

Output:
-1
Iron Rods - Strictly Increasing Order
There are N iron rods arranged in a row based on the height in ascending order. A boy cuts
the iron rods in strictly increasing order so that the absolute difference between the heights
of every two consecutive iron rods is 1. The boy never cuts the first iron rod. After cutting
the N-1 iron rods, he starts melting and making new iron rods with the remaining rods. The
boy wants to place as many new rods as possible to the right side of the N rods without
violating the strictly increasing order of height.
The program accepts N integers representing the heights of the N iron rods as the input. The
program must print the heights of the iron rods after cutting and making the new rods as the
output.

Boundary Condition(s):
2 <= N <= 100
1 <= Each integer value <= 10^5

Input Format:
The first line contains N.
The second line contains N integer values separated by a space representing the heights of
the N iron rods.

Output Format:
The first line contains the integer values separated by a space representing the heights of
the iron rods based on the given conditions.

Example Input/Output 1:
Input:
4
2 5 8 12

Output:
234567

Example Input/Output 2:
Input:
5
5 6 7 10 21

Output:
5 6 7 8 9 10

Example Input/Output 3:
Input:
7
18 19 20 21 22 23 24

Output:
18 19 20 21 22 23 24
Max Call Duration - Call Logs
The program must accept the outgoing call logs of a mobile number as the input. Each call
log contains the mobile number, call start time and end time. The program must print the
mobile number having the maximum call duration. If there are two or more such mobile
numbers having the maximum call duration, then the program must print them in the order
of their occurrence.

Boundary Condition(s):
2 <= N <= 50

Input Format:
The first line contains N.
The next N lines, each contains the mobile number, call start time and end time separated by
a space.

Output Format:
The lines contain the mobile number(s) having the maximum call duration.

Example Input/Output 1:
Input:
5
9876543210 [Link] [Link]
9998887775 [Link] [Link]
9876543210 [Link] [Link]
9998887775 [Link] [Link]
9998887775 [Link] [Link]

Output:
9876543210

Explanation:
9876543210 (2 times) -> Total duration: 92 + 255 = 347 seconds.
9998887775 (3 times) -> Total duration: 10 + 108 + 73 = 191 seconds.
The mobile number 9876543210 is having the maximum call duration.
Hence the output is 9876543210.

Example Input/Output 2:
Input:
6
9876543210 [Link] [Link]
9998887775 [Link] [Link]
9876543210 [Link] [Link]
9998887775 [Link] [Link]
9998887775 [Link] [Link]
9998887775 [Link] [Link]

Output:
9876543210
9998887775
Find Area - Radius or Diameter
The program must accept an integer Q as the input. If
the value of Q is 1, then the radius of a circle is passed
as the input. If the value of Q is 2, then the diameter of
a circle is passed as the input. The program must print
the area of the circle with the precision up to 2 decimal
places as the output.

Your task is to fill in the missing lines of code in the


class Circle so that the program runs successfully.

Example Input/Output 1:
Input:
1
5

Output:
78.57

Example Input/Output 2:
Input:
2
7.5

Output:
44.20
function getTotalPrice

The function/method getTotalPrice accepts an argument str


representing a text. The text contains the prices of some
items as floating point values.

The function/method getTotalPrice must return a floating


point value representing the total price of the items
mentioned in the text.

Your task is to implement the function getTotalPrice so that


the program runs successfully.

Note: The total price will be printed with the precision up to 2


decimal places.

IMPORTANT: Do not write the main() function as it is already


defined.

Example Input/Output 1:
Input:
Cost of 5 pens is 50.98 rupees. Cost of a pencil is 4.25.

Output:
55.23

Example Input/Output 2:
Input:
A is 5.60, B is 2.14, C is 100.58 and D is 50.6.

Output:
158.92
Boats & Ships - North or West
The program must accept a character matrix of size R*C representing a port as the
input. The character asterisk (*) represents water. The character hash symbol (#)
represents a boat. Two consecutive hash symbols (vertically or horizontally)
represent a ship. The vertical ships can move only towards the north. The
horizontal ships can move only towards the west. The boats can move towards
north or west. The boats and ships leave the port based on the following
conditions.
- Every odd minute, the first occurring boat or the vertical ship in each column
leave the port (towards north).
- Every even minute, the first occurring boat or the horizontal ship in each row
leave the port (towards west).
- A boat or ship cannot move if there is another boat or ship on its way.
The program must print the number of minutes it takes to empty the port as the
output.

Input Format:
The first line contains R and C separated by a space.
The next R lines, each contains C characters separated by a space.

Output Format:
The first line contains the number of minutes it takes to empty the port.

Example Input/Output 1:
Input:
76
##*##*
**#**#
#*#*#*
****#*
#*##*#
*#****
****#*

Output:
5
Example Input/Output 2:
Input:
67
***#*##
##*****
**#**#*
*#*#*#*
*#*#**#
#*#**#*

Output:
4
Multiply the Unit Digit in Reverse Order
The program must accept N integers as the input. The
program must multiply the unit digit of each integer
with
itself and print the product values in reverse order as
the output.

Input Format:
The first line contains N.
The second line contains N integers separated by
space.

Output Format:
The first line N integers separated by a space.
Example Input/Output l:
Input:
5
24 17 5 36 214
The program must accept two characters CHI, CH2, and an integer N as the input. The program
must print the desired
pattern as shown in the Example Input/Output section.
Boundary Condition(s):

Input Format:
The first line contains the values Of CHI, CH2 and N separated by space(s).

Output Format:
The first N lines containing the desired pattern as shown in the Example Input/Output section.
:
Input:
Output:
ACCCCCC
AACCCCC
AAACCCC
AAAACCC
AAAAAAC
AAAAAAA
Print Next Even Digit

Given a number N, the program must print the next even digit
for each of the digits in N,

Boundary Condition(s):
1 <= N <= 999999999

Input Format:
The first line contains N.

Output Format:
The first line contains the specified output.

Example Input/Output 1:
Input:
123

Output:
244

Example Input/Output 2:
Input:
789

Output:
800
Print the Floating Point Values

The program must accept a string value S as the input.


The program must print all the floating point values in
the string S as output.

Boundary Condition(s):
3 <= Length of String S <= 49

Input Format:
The first line contains the string value S.

Output Format:
The list of lines contain all the float values in S.

Example Input/Output 1:
Input:
hello12.34madam45.67

Output:
12.34
45.67
The praogram must accept a str ing value S as the input.
The program must pc int the expanded string as shown in
the
Example Input/Output section.
gouruiary Condition(s):
1 Length of S 100
Inmlt Format:
The first line contains the values of string S.
Output Format:
The first line contains the expanded string as shown in
the Example section.
lncNJt/[Link] I:
Input:
orange
Output:
egengeangerangeorange
Explanation:
The string orange is expanded as e ge nge range (Mange.
Hence the output is egerweangeratWorar%e
Vxanwe 7:
Input:
Water
rerteraterWater
Rearrange Matrix without Duplicates in Each Column

The program must accept an integer matrix of size R*C as input.


The program must print YES if the given matrix can be rearranged
in such a way that each column must not contain any duplicates.
Else the program must print NO as the output.

Boundary Condition(s):
1 <= R, C <= 50
0 <= Matrix Element <= 999999

Input Format:
The first line contains the value of R and C separated by space(s).
The next R lines contain C integers separated by space(s).

Output Format:
The first line contains either "YES" or "NO".

Example Input/Output 1:
Input:
33
455
467
757

Output:
YES

Explanation:
The given matrix can be rearranged as
445
556
777
The program must accept an integer N and a digit D as the
input. The program must print the sum of the
integers from I to N which have the unit digit as D as the
output. If there is no such integer from I to N
then the program must print -1 as the output.
Boundary Condition(s):
1 1000
Input Format:
The first line contains the values of N and D seperated by
space
Output Format:
The first line contains either the sum of the integers from
1 to N which have the unit digit as D or -1.
Example Input/Output I:
Input:
303
Output:
39
Explanation:
The integers from 1 to 30 which have the unit digit as 3
are 3, 13 and 23.
So the sumis39(3+13+23Y
Hence the output is 39
Example Input/Output 2:
Input:
57
Output:
-1
Remove Alphabet

The program must accept two alphabets CH1 and CH2


as the input. The program must print the output
based on the following conditions.
- If CH1 is either 'U' or 'u' then print all the uppercase
alphabets except CH2.
- If CH1 is either 'L' or 'l' then print all the lowercase
alphabets except CH2.
- For any other values of CH1 then print INVALID.

Example Input/Output 1:
Input:
Uv

Output:
ABCDEFGHIJKLMNOPQRSTUWXYZ

Example Input/Output 2:
Input:
LC

Output:
abdefghijklmnopqrstuvwxyz
The program must accept three integers M. N and X as the
input. The program must print the sum of
multiples of X from M to N as the output If there is no
multiple of X from M to N then the program must
print -1 as the output.
Boundary Condition(s):
100
Input Format:
The first line contains the values of M. N and X separated by
space(s).
Output Format:
The first line contains either the sum of multiples of X from M
to N or -1-
Example Input/Output 1:
Input:
5253
Output:
105
Explanation:
The multiples of 3 from 5 to 25 are 6, 9, 12, 15, 18, 21 and 24.
so their sum is 105 9+ 12 + 15 + 18+21+24).
Hence the output is 105
Example Input/Output 2:
Input:
10 20 33
Output:
.1
The program must accept an integer N as the input.
The program must print the factors of N in
descending order as the output
Boundary Condition(s):
1 e-N«-IOOO
Input Format:
The first line contains the value of N.
Output Format:
The first line contains the factors of N in descending
order separated by space(s).
Example Input/Output I:
Input:
24
Output:
2412864321
Explanation:
The factors of 24 in descending order are 24, 12, 8, 6, 4,
3, 2 and I.
Hence the output is 2412 8 6 4 3 2 1
Example Input/Output 2:
Input:
11
Output:
111
Remove Characters Adjacent to Vowels

Accept a string as input. The program must print the


string by removing the characters if there is at least one
vowel adjacent to it.

Boundary Condition(s):
1 <= Length of String <= 1000

Input Format:
The first line contains the string.

Output Format:
The first line contains the string with the characters
adjacent to vowels removed from it.

Example Input/Output 1:
Input:
thinker

Output:
tie

Example Input/Output 2:
Input:
table

Output:
ae
The program must accept a string value S contains
only alphabets as the input The program must print
an alphabet from S which has occurred first in the
alphabetical order as the output.
Note: All alphabets are only lower-case in S.
Boundary Condition(s):
1 Length of S 100
Input Format:
The first line contains a string S.
Output Format:
The first line contains an alphabet from S which has
occurred first in the alphabetical order
Example Input/Output I:
Input:
qwerty
Output:
Explanation:
In the word qwerty, the character 'e' has occurred first
in the alphabetical order.
Hence the output is e
Example Input/Output 2:
Input:
zxsvwu
Output:
7
Remove First X and Last Y Characters

A string S and two integers X and Y are given as input. The


program must print the string after removing the first X
characters and last Y characters.

Boundary Condition(s):
2 <= Length of String <= 1000

Input Format:
The first line contains the string S, X and Y separated by
space(s).

Output Format:
The first line contains the string after removal of characters.

Example Input/Output 1:
Input:
marshmallow 2 3

Output:
rshmal

Example Input/Output 2:
Input:
geography 3 1

Output:
graph
The program must accept an integer matrix Of size NXN and
an integer K as the input. The propam must remove the
first K rows and the first K columns from the matrix. Then the
program must print the modified matrix as the output
Boundary Condition(s):
•999 Each element of the matrix < — 999
1 c-K<N
Input Format:
The first line contains the value of N.
The next N lines each contain N integers separated by
space(s).
The line contains the value of K.
Output Format:
The first N-K lines each contain N-K interrs of the modified
matrix separated by a space
Example Input/OutßkJt I:
Input:
4
2021016
2017 116
141613
10 2 174
2
Output:
13
174
Explanation:
Here the value of K is 2. So remove the first 2 rows and the
first 2 columns from the matrix.
Hence the output is
13
174
Remove S2 Characters from S1

Two string values S1 and S2 are passed as input to the program. The
program must remove all the characters that are present in S2 from
S1 and print the resulting string value as the output.

Boundary Condition(s):
1 <= Length of S1 <= 1000
1 <= Length of S2 <= 1000

Input Format:
The first line contains S1.
The second line contains S2.

Output Format:
The first line contains the string value as mentioned above.

Example Input/Output 1:
Input:
apple
pan

Output:
le

Example Input/Output 2:
Input:
economical
mango

Output:
ecicl
The program must accept a stringS as the input- The program
must print the desired pattern as shown
in the Example Input/Output section
Note; The length of S is always odd.
Boundary Condition(s):
1 Length of S 99
Input Format:
The first line contains the value of string S.
Output Format:
The list of lines containing the desired pattern as shown in
the Example Input/Output section.
Example Input/Output 1:
Input:
skillrack
Output:
skillrack
•carllik
"illra
•••rll
Example Input/Output 2:
Input:
first
Output:
first
•sri
Inverted Triangle with Numbers

The program must accept an integer N as the input.


The program must print the desired pattern as
shown in
the Example Input/Output section.

Boundary Condition(s):
Input Format:
The first line contains the value of N.
Output Format:
The first N lines containing the desired pattern as
shown in the Example Input/Output section.

middle integers In range


integers are passed as input to the program. The program must
print YES if all the N-2 integers between
It-st and last integers are greater than the first integer and lesser
than the last (Nth) integer. Else the program
must print NO es the output.

undary Condition(s):
1 N 100

nput Format:
e first line contains the value of N.
e second line contains N integers separated by a space.
utput Format:
e first line contains either YES or NO
The program must accept an integer N as the input.
The program must print the desired pattern as shown
in
the Example Input/Output section.
Boundary Condition(s):
1 GNGIOA15
Input Format:
The first line contains the integer N.
Output Format:
The list of lines containing the desired pattern as
shown in the Example Input/Output section.
Example Input/Output l:
Input:
43785
Output:
4
33
8888
55555
Example Input/Output 2:
Input:
10001
Output:
1
00
ooo
0000
Repeating Character Toggle Last

The program must accept a string S which contains only


lower case alphabets and then search for successively
repeating characters in S. Then the program must toggle the
case (convert it to Upper Case) of the last repeating character
and print the resulting string value as the output.

Boundary Condition(s):
1 <= Length of S <= 1000

Input Format:
The first line contains S.

Output Format:
The first line contains the output string value.

Example Input/Output 1:
Input:
aaa

Output:
aaA

Example Input/Output 2:
Input:
aahhjhszz

Output:
aAhHjhszZ
The program must accept a string S as the input. The program must
find the count Of alphabets M which are
present bet'vveen the alphabets a and m (inclusive) in the String S.
Then the program must find the count Of
alphabets N which are present betvveen the alphabets n and z
(inclusive) in the String S. Finally, the program
must print the output based on the following conditions,
-If M is greater than N then print FIRSTHALF.
-If N is greater than M then print SECONDHALF.
-If M and N are equal then print •l.
[Link]; The alphabets in S are only in lower case.
Boundary Condition(s):
I Length of S 100
Input Format:
The first line contains the string S.
Output Format:
The first line contains FIRSTHALF or SECONDHALF or -1.
Example Input/Output I:
Input:
abcdxyz
Output:
Fl RSTHALF
Explanation:
The alphabets a, b, c and d are present between the alphabets a and
m. So their count M is 4.
The alphabets x, y and z ere present benjveen the alphabets n and z.
So their count N is 3.
Here M is greater than N. So FIRSTHALF is printed.
Example Input/Output 2:
Input:
ryasnw
Output:
SECONDHALF
Replace Continuously Repeated Characters

A string S is passed as input. The program must replace all the


continuously repeating characters in the string with just one
occurrence of that specific character which is repeating.

Boundary Condition(s):
1 <= Length of string <= 1000

Input Format:
The first line contains the string S.

Output Format:
The first line contains the modified string.

Example Input/Output 1:
Input:
hello

Output:
helo

Example Input/Output 2:
Input:
aabbaaabbcccc

Output:
ababc
The program must accept an integer N as the input. The
program must print valid if N is a prime number
or an even number. Else the program must print invalid as the
output.
Boundary Condition(s):
Input Format:
The first line contains the integer N.
Output Format:
The first line contains either valid or invalid.
Example Input/Output 1:
Input:
53
Output:
valid
Explanation:
The integer 53 is a prime number.
Hence the output is valid
Example Input/Output 2:
Input:
IOO
Output:
valid
Explanation:
The integer 100 is an even number.
Hence the output is valid
Example Input/Output 3:
Input:
Output:
invalid
Replacing Digit With Values In Position

Given an integer N as input, the program must


replace every digit of N with the value in the
position and print the resultant number.

Boundary Condition(s):
1 <= N <= 999999999

Input Format:
The first line contains value of integer N.

Output Format:
The first line contains the resultant number after
replacing every digit of N with the value in the
position.

Example Input/Output 1:
Input:
999999993

Output:
333333339
The program must accept an integer N as the input. The
program must print the sum of the first N terms in
the series given below.
The order of the series must be 1, -2, 3, -4, 5, -6 and so on
(All the odd terms in the series formed from the
positive odd numbers and all the even terms in the series
formed from the negative even numbers).
Boundary Condition(s):
Input Format:
The first line contains the integer N.
Output Format:
The first line contains the sum of the first N terms in the
above mentioned series.
Example Input/Output I:
Input:
5
Output:
3
Explanation:
The first 5 terms are 1, -2, 3, -4 and 5 and their sum is 3 (1
Hence the output is 3
Example Input/Output 2:
Input:
8
Output:
-4
Reverse Last X Digits

Given two numbers N and X as input, the program must print


the value of N with last X digits reversed.

Boundary Condition(s):
1 <= N <= 999999999
0 <= X <= 9

Input Format:
The first line contains the value of N.
The second line contains the value of X.

Output Format:
The first line contains the value of N with last X digits
reversed.

Example Input/Output 1:
Input:
12345
2

Output:
12354

Example Input/Output 2:
Input:
123459823
5

Output:
123432895
Reverse Odd Position in String

Given a string S, the program must reverse the


characters present in odd positions of the string S.

Boundary Condition(s):
1 <= Length of S <= 100

Input Format:
The first line contains S.

Output Format:
The first line contains the string value with the
characters in the odd positions of S reversed

Example Input/Output 1:
Input:
barcode

Output:
eaocrdb

Example Input/Output 2:
Input:
Mediterranean

Output:
neeiaerrtndaM
Reversed Alphabet Position

Given a string S, for each letter in the string the


program must print the reversed alphabet position
letter.

Boundary Condition(s):
1 <= Length of String <= 1000

Input Format:
The first line contains S.

Output Format:
The first line contains the specified output.

Example Input/Output 1:
Input:
abc

Output:
zyx

Example Input/Output 2:
Input:
Yarn

Output:
Bzim
The program must accept N intews as the input. The prop-am
must swap the unit diet of the first integer and the
unit diet of Nth integer. The program must swap the unit diet of
the second integer and the unit digit of (N-l)tn
integer and so on. Finally. the program must print the modified
N integers as the output
Boundary Condition(s):
I IOA5
Input Format:
The first line contains the value of N.
The second line contains N integers separated by space(s).
Output Format:
The first line contains the modified N integers separated by
space(s).
Example I:
Input:
4
98 5015 19
Output:
9955 1018
Explanation:
The first integer is 98 and its unit digit is 8.
The fourth integer is 19 and its unit diet is 9.
After swappingthe unit digits of 98 and 19.98 becomes 99 and
19 becomes 18.
The second integer is 50 and its unit digit is O.
The third integer is 15 and its unit digit is 5.
After swappingthe unit digits of 50 end 15.50 becomes 55 and
15 becomes IO
Hence the output is 99 55 IO 18
Example Input/Output 2:
Input:
5
8113 8 68 54197
Output:
'''
Reversed Words in Even Positions

Given a string S as the input with two or more words in it,


the program must reverse the order of the words in S.
Then the program must reverse each word in the even
positions. The resulting words in the modified order must
be printed as the output.

Boundary Condition(s):
10 <= Length of S <= 1000

Input Format:
The first line contains the string with two or more words
separated by space(s).

Output Format:
The first line contains the reversed string with words in
the even position reversed.

Example Input/Output 1:
Input:
one two three four

Output:
four eerht two eno

Example Input/Output 2:
Input:
one two three four five

Output:
five ruof three owt one
'''
The program mi-JSt accept string S as the input. The program
mi-JSt print the alphabets Of S in reversal
alphabetical order as the OUtput.
Note: The string S always contain only lowercase alphabets.
Boundary Condition(s):
1 Length of S 100
Input Format:
The first line contains the string S.
Output Formae
The first line contains the alphabets cf S in reversal
alphabetical order.
Example Input/Output 1:
Input:
orange
Output:
rongea
Explanation:
In the string orange, the alphabets in reversal alphabetical
order are r o n g e a.
Hence the output is rongea
Example Input/Output 2:
Input:
Ouput:
Right Angled Triangle Check
1
Three sides of a triangle are passed as input. The program
must print yes if the sides form a right angled triangle. Else
the program must print no.

Boundary Condition(s):
1 <= Length of the sides <= 999999999

Input Format:
The first line contains three integers denoting the length of
the sides separated by a space.

Output Format:
The first line contains yes or no

Example Input/Output 1:
Input:
543

Output:
yes

Example Input/Output 2:
Input:
856

Output:
no
The program must accept a string S as the input. The program
must print the alphabets of S in reversal
alphabetical order as the output.
Note: The string S always contain only lowercase alphabets.
Boundary Condition(s):
I Length of S 100
Input Format:
The first line contains the string S.
Output Format:
The first line contains the alphabets of S in reversal
alphabetical order.
Example Input/Output l:
Input:
orange
Output:
rongea
Explanation:
In the string orange, the alphabets in reversal alphabetical
order are r o n g e a.
Hence the output is rongea
Example Input/Output 2:
Input:
Ouput:
The program must accept a string value S as the input. The
program must print the desired pattern as
shown in the Example Input/Output section.
Boundary Condition(s):
Input Format:
The first line contains the string S.
Output Format:
The first N lines containing the desired pattern as shown in the
Example Input/Output section.
Example Input/Output I:
Input:
happy
Output:
Example Input/Output 2:
Input:
orange
Output:
ar
e gn
The program must accept an integer N as the input The
progarn must print the first N terms in the series the
output.
Note: The order Of series must be 1/4, 1/2, 3/4. I. 5/4,
3/2.7/4, 2.9/4, 5/2 and so on.
Boundary Condition(s):
Input Format:
The first line conatins the integer N.
Output Format:
The first line contains N terms in the series separated
by space-
Example Input/Output 1:
Input:
6
Output:
1/4 1/2 3/415/43/2
Example Input/Output 2:
Input:
9
Output
1/4 1/2 3/4 1 5/4 3/2 7/4 2 9/4
Occurrences X and Y

The program must accept N integers and two integers X, Y as the


input. The program must print YES if the
number of occurrences of X is greater than or equal to the
number of occurrences of Y. Else the program
must print NO as the output.

Boundary Condition(s):
1 X, Y, Each integer value IOA8

Input Format:
The first line contains the value Of N.
The second line contains N integers separated by space(s).
The third line contains the values Of X and Y separated by a
space.
Output Format:
The first line contains either YES or NO.

Triangle Pattern - Multiples of X


The program must accept tvvo integers N ard X as the input. The
program must print the desired pattern as
shown in the Example Input/Output section.
Boundary Condition(s):
I X 100
Input Format:
The first line contains the values of N and X separated by a space.
Output Format:
The first N lines containing the desired pattern as shown in the
Example Input/Output section.
Rotate K Times

The program must accept N integers and K (number of rotation(s)) as


input. The program must print N integers after K rotation(s) in clockwise
direction as output.

Boundary Condition(s):
1 <= N <= 999
1 <= K <= 9999999999

Input Format:
The first line contains the integer value of N.
The second line contains N integers separated by space(s).
The third line contains the integer value of K.

Output Format:
The first line contains N integers separated by space(s).

Example Input/Output 1:
Input:
5
12345
2

Output:
45123

Explanation:
After the first rotation, the given array elements are 5 1 2 3 4.
After the second rotation, the given array elements are 4 5 1 2 3.
So, 4 5 1 2 3 is printed.

Example Input/Output 2:
Input:
9
12 23 34 45 6 67 78 89 90
15

Output:
45 6 67 78 89 90 12 23 34
The program must accept a string S as the input, The program
must count the number of occurrences of
each vowel in the string S and print all the vowels along with their
count as the output. The order cf vowels
must be a, e, i, o and u.
Note: All the alphabets in S ere only in lowercase.
Boundary Condition(s):
I Length Of S •$ 1000
Input Format:
The first line contains the string S.
Output Format:
The first line contains the vowel a with its count separated by a
space.
The second line contains the vowel e with its count separated by
a space.
The third line contains the vowel i with its count separated by a
space.
The fourth line contains the vowel o with its count separated by e
space.
The fifth line contains the vowel u with its count separated by a
space.
Example Input/Output l:
Input:
bcdefghijklmnopqrstvwxyz
Output:
Explanation:
The vowel e has occurred once.
The vowel i has occurred once.
The vowel o has occurred once.
Same Characters in Zigzag Matrix
Accept a matrix of size NxN containing only characters as input. The program must print the characters which
are in the same positions in
the forward and the reverse zig-zag traversal. If there is no character in the same position in such traversal
then print -1 as the output.

Boundary Condition(s):
2 <= N <= 20

Input Format:
The first line contains the value of N.
The next N lines contain N characters separated by space.

Output Format:
The first line contains the characters which are in the same positions in the forward and the reverse zig-zag
traversal separated by space(s) or -1.

Example Input/ Output 1:


Input:
5
abcde
fghij
klmno
fghij
krcfa

Output:
achm

Explanation:
In the forward traversal, the matrix contains a, b, c, d, e, j, i, h, g, f, k, l, m, n, o, j, i, h, g, f, k, r, c, f and a.
In the reverse traversal, the matrix contains a, f, c, r, k, f, g, h, i, j, o, n, m, l, k, f, g, h, i, j, e, d, c, b and a.
While traversing in the forward and reverse direction, the characters in the same positions are a, c, h and m as
highlighted in blue color.

Example Input/ Output 2:


Input:
6
mohngi
tsvuhr
glmnno
ocbdfg
rhvvst
ogigfe

Output:
grhvstgo

Example Input/ Output 3:


Input:
4
abcd
fghi
klmn
fghi

Output:
-1
The program must accept an integer array of size N
containing only Os and I's as the input. The program
must brins all the zeros to the front and all the ones to the
end of the array. Then the program must print
the modified array as the output.
Boundary Condition(s):
Array Element I
Input Format:
The first line contains the value of N.
The second line contains N integers separated by space(s).
Output Format:
The first line contains N integers of the modified array
separated by a space.
Example Input/Outupt l:
Input:
7
0110100
Output:
0000111
Explanation:
There are 4 zeros and 3 ones in the input,
So print ell the zeros at the beginning and all the ones at the
end.
Hence the output is 00001 1 1
Example Input/Outupt 2:
Input:
4
1110
Output:
Olli
The program must accept an integer N as the input. The
program must print the desired pattern as shown
the Example Input/Output section.
Boundary Condition(s):
1 N 100
Input Format:
The first line contains the value of N.
Output Format:
The first N lines containing the desired pattern as shown in
the Example Input/Output section.
Example Input/Output I:
Input:
5
Output:
12345
12345
Example Input/Output 2:
Input:
8
Output:
12345678
12345678
First and Last N Characters
The propam must accept a string S contains only alphabets and an
integer N as the input. The prop-am must print the
first N alphabets in the string and then print the last N alphabets in
the string as the output.

Boundary Condition(s):
2 Length of S 100
1 N Length of S

Input Format:
The first line contains the string S
The second line contains the integer N.

Output Format:
The first line contains the first N alphabets and the last N alphabets
Skip Traverse from Last

An array of N integers is given as input. The program must traverse


and print the array in reverse order with the following rules. When
encountering an even integer skip the next element. When
encountering an odd integer skip the next two elements. The array is
traversed starting from the last element.

Boundary Condition(s):
2 <= N <= 10000

Input Format:
The first line contains N.
The second line contains N integers separated by space(s).

Output Format:
The first line contains the traversed integers separated by a space.

Example Input/Output 1:
Input:
6
23 17 32 27 14 63

Output:
63 32 23

Example Input/Output 2:
Input:
7
37 19 83 74 3 2 82

Output:
82 3 19
The program must accept a string S and r•uo
characters CHI and CH2 as the input The program
must
replace all the occurrences of CHI by CH2 in the string
S. Then the program must print the modified string as
the output.
Boundary Condition(s):
1 Length Of S G 1
Input Format:
The first line contains the value of the string S.
The second line contains the value cf CHI and CH2
separated by a space.
Output Format:
The first line contains the modified string.
Example Input/Output l:
Input:
terrorist
Output:
teddodist
Explanation:
All the occurrences of 'r' are replaced by 'd' in the
string "terrorist".
Hence the output is teddodist
Example Input/Output 2:
Input:
manipulasicn
Output:
manipulation
Sort Odd Even Array

Given an array of N integers, the program must sort the integers


present in odd positions if N is odd else must sort the integers
present in even positions. The sorting must be in ascending order.

Boundary Condition(s):
1 <= N <= 99999

Input Format:
The first line contains N.
The second line contains N integers separated by space.

Output Format:
The first line contains N integers separated by space.

Example Input/Output 1:
Input:
7
12 45 14 21 57 12 9

Output:
9 45 12 21 14 12 57

Example Input/Output 2:
Input:
10
78 121 34 56 12 34 89 18 33 90

Output:
78 18 34 34 12 56 89 90 33 12
The program must accept N integers (where N is always even)
as the inpu'„ The program must sort every
uo integers in ascending order among the N integers. Then the
program must print the modified value of
all the N integers as the output.
Boundary Condition(s):
2 G NG 100
I Each integer value 9999
Input Format:
The first line contains the value of N.
The second line contains N integers separated by space(s).
Output Format:
The first line contains N integer values separated by a space.
Example Input/Output 1:
Input:
4
10524
Output:
51024
Explanation:
The first two integers are IO and 5. So sort them in ascending
order.
The next two integers are 2 and 4, They are already sorted in
ascending order. So no need to sort them
again.
Hence the output is 5 IO 2 4
Example Input/Output 2:
Input:
8
36 22 10
Output:
22 36 87 87 44 54 10 93
he program must accept a stringS contains only al phabets
and an integer N as the input. The program must print the
'rst N alphabets in the string and then print the last N
alphabets in the string as the output-
Boundary Condition(s):
2 Length of S 100
I N Length of S
Input Format:
The first line contains the string S
he second line contains the integer N.
he first line contains the first N alphabets and the last N
alphabets
Example Input/Output I:
Input:
Engineering
3
Output:
Enging
Explanation:
he first 3 alphabets in the string "Engineering • are E n g.
he last 3 alphabets in the string "Engneering• are i n g.
Hence the output is Eneng
Example Input/Output 2:
Input:
irst
5
Output:
irstfirst
Sort One or Two Digit Numbers

N numbers are passed as input. The program must sort only the
numbers with one or two digits in it among the N numbers. Other
numbers are retained in their same positions.

Boundary Condition(s):
1 <= N <= 1000

Input Format:
The first line contains N.
The second line contains N numbers separated by space(s).

Output Format:
The first line contains N numbers separated by a space.

Example Input/Output 1:
Input:
6
12 109 3 751 89 56

Output:
3 109 12 751 56 89

Example Input/Output 2:
Input:
9
534 95 805 605 315 42 762 523 23

Output:
534 23 805 605 315 42 762 523 95
Sort Strings -Unique Alphabets Count

N string values are passed as input. The program must sort and print the strings based on
the count of unique alphabets in them. If two strings have same unique alphabet count,
then sort them based on lexicographical order. Sorting based on the count of unique
characters must be done in descending order (that is the string having the highest unique
character count must be printed first).

Boundary Condition(s):
1 <= N <= 100
1 <= Length of string <= 1000

Input Format:
The first line contains N.
The next N lines contain the values of N strings.

Output Format:
The first N lines contain the string values sorted based on the given conditions.

Example Input/Output 1:
Input:
3
bubble
telegram
munch

Output:
telegram
munch
bubble

Example Input/Output 2:
Input:
4
sit
miner
flood
temple

Output:
miner
temple
flood
String Alphabets Position Sum

Given an input string S of length L containing only lower case


alphabets, the program must print the sum of the positions of the
alphabets. Position of a is 1, b is 2 and so on till z whose position is 26.

Boundary Conditions:
1 <= L <= 100

Input/ Output Format:


Input:
The first line contains the value of String S.

Output:
The first line contains the sum of positions of the lower case
alphabets in S.

Example Input/Output 1:
Input:
abca

Output:
7

Explanation:
The sum of positions is 1+2+3+1 = 7

Example Input/Output 2:
Input:
azd

Output:
31
String Characters Interlace

Given an input string S, accept the input string S and print the string
in the interlaced order as shown in the example Input/Output
section.

Input Format:
The first line contains the value of String S (may contain letters, white
spaces, special characters, and numbers).

Output Format:
The string S has to be printed in the order of 1st character and (N-1)
character, 2nd character and (N-2) character and so on where N is the
length of the string S.

Boundary Conditions:
1 <= Length of S <= 100

Example Input/Output 1:
Input:
abc321

Output:
a1b2c3

Example Input/Output 2:
Input:
pqrs-wxyz

Output:
pzqyrxsw-
String With Most Vowels

Two Strings S1 and S2 are given as input. The program must


print the string with the most number of vowels. If two strings
have the same number of vowels, print the string with greater
length.

Boundary Condition(s):
1 <= length of strings <= 1000

Input Format:
The first line S1 and S2 separated by space(s).

Output Format:
The first line contains a string.

Example Input/Output 1:
Input:
adder divider

Output:
divider

Example Input/Output 2:
Input:
important welcome

Output:
important
Given a string S and an integer N as the input, the program must split the string into groups
whose size is N and print them as the
output in separate lines in a zig zag manner. If the last group size is less than N then the
remaining letters must be filled with
asterisk as shown in the Example Input/Output.

Input Format:
The first line contains S.
The second line contains N.

Output Format:
LENGTH(S)/N + LENGTH(S)%N lines containing the desired pattern.

Boundary Conditions:
4 <= LENGTH(S) <= 500
2 <= N <= LENGTH(S)

Example Input/Output 1:
Input:
ENVIRONMENT
3

Output:
ENV
ORI
NME
*TN

Example Input/Output 2:
Input:
ENVIRONMENT
4

Output:
ENVI
MNOR
ENT*

Example Input/Output 3:
Input:
EVERYDAY
2

Output:
EV
RE
YD
YA
Lower Triangle Matrix

Given a square matrix of size N as the input, print the lower triangular matrix form
of the matrix as shown in the Example Input/ Output section.

Boundary Conditions:
1 <= N <= 50

Input/ Output Format:


Input:
The first line contains the value of N.
The next N lines contain the values of the matrix.

Output:
The first N lines represent the lower triangular matrix format of the matrix.

Example Input/ Output 1:


Input:
3
123
456
789

Output:
1
45
789

Example Input/ Output 2:


Input:
4
1234
5678
9123
4567

Output:
1
56
912
4567
Structure Laptop with Minimum Cost

The program must accept an integer X followed by the brand name or the
product number of N laptops with their costs.
The program must print either the brand name or the product number of a
laptop which has the minimum cost among N laptops.
If X is 1 then X is followed by the brand name. If X is 2 then X is followed by the
product number. Fill in the missing lines of code so that
the program runs successfully.
Note: If two or more laptops have the same cost then print the information of
first occurring laptop.

Input Format:
The first line contains the value of N.
The next N lines contain an integer, a string (brand name) or an integer (product
number) and an integer (cost) separated by space(s).

Output Format:
The first line contains either a string (brand name) or an integer (product
number) of the laptop which has the minimum cost among N laptops.

Example Input/Output 1:
Input:
4
1 Sony 70000
2 89793456 30000
2 65765767 60000
1 HP 45000

Output:
89793456

Example Input/Output 2:
Input:
3
1 Samsung 50000
2 76576777 45000
1 Acer 20000

Output:
Acer
Given an integer N, the program must print the pattern as shown in
the Example Input/Output section.

Boundary Condition(s):
1 <= N <= 100

Input Format:
The first line contains N.

Output Format:
The pattern is printed as shown in the Example Input/Output section.

Example Input/Output 1:
Input:
4

Output:
1*2*3*4
*7*6*5*
**8*9**
***10***

Example Input/Output 2:
Input:
5

Output:
1*2*3*4*5
*9*8*7*6*
**10*11*12**
***14*13***
****15****
2*2 Sub Matrix with Sum

A matrix of size R*C and an integer S are passed as the input to the program.
The program must print the 2*2 submatrix whose sum is S.
If more than one such submatrices exist, print the first occurring submatrix
(when traversed from top to bottom in the matrix and from
left to right in each row).

Boundary Condition(s):
2 <= R, C <= 100

Input Format:
The first line contains the value of R and C separated by space(s).
The next R lines contain C integers separated by space(s).

Output Format:
The first two lines contain the submatrix.

Example Input/Output 1:
Input:
33
23 12 45
25 26 29
33 35 36
119

Output:
25 26
33 35

Example Input/Output 2:
Input:
43
48 10 77
4 99 15
75 29 97
40 84 62
272

Output:
29 97
84 62
Cut the Cake

Initial size of a cake and values of position of N cuts are passed as the input.
The program must print the size of largest cake piece after the N cuts.

Boundary Condition(s):
10 <= N <= 999999

Input Format:
The first line contains the size of cake.
The second line contains the values of position of N cuts in ascending order.

Output Format:
The first line contains the size of largest cake piece.

Example Input/Output 1:
Input:
16
358

Ouput:
8

Explanation :
After the first cut the size of piece 1 is 3, after the second cut the size of piece
2 is 2,after the third cut the size of piece 3 is 3 and after the fourth cut the size
of piece 4 is 8.
Finally the largest cake piece is 8.

Example Input/Output 2:
Input:
25
5 10 16

Ouput:
9
T String Pattern

Given two strings S1 and S2, the program must print the pattern as shown in the
Example Input/Output section.

Note:
The string S1 always comes in the first row.
The string S2 is printed along the last matching column of S1.

Boundary Condition(s):
1 <= Length of S1, S2 <= 100

Input Format:
The first line contains S1.
The second line contains S2.

Output Format:
The pattern is printed as shown in the Example Input/Output section.

Example Input/Output 1:
Input:
trophy
panther

Output:
trophy
---a--
---n--
---t--
---h--
---e--
---r--

Example Input/Output 2:
Input:
morning
ninja

Output:
morning
-----i-
-----n-
-----j-
-----a-
X in Rectangular Pattern

The program must accept an integer N as the input. The program must print the
pattern as shown in the Example Input/Output sections.

Boundary Condition(s):
5 <= N <= 50

Input Format:
The first line contains the value of N.

Output Format:
The first N lines contain the desired pattern as shown in the Example Input/Output
sections.

Example Input/Output 1:
Input:
15

Output:
***************
**-----------**
*-*---------*-*
*--*-------*--*
*---*-----*---*
*----*---*----*
*-----*-*-----*
*------*------*
*-----*-*-----*
*----*---*----*
*---*-----*---*
*--*-------*--*
*-*---------*-*
**-----------**
***************

E
xample Input/Output 2:
Input:
20

Output:
********************
**----------------**
*-*--------------*-*
*--*------------*--*
*---*----------*---*
*----*--------*----*
*-----*------*-----*
*------*----*------*
*-------*--*-------*
*--------**--------*
*--------**--------*
*-------*--*-------*
*------*----*------*
*-----*------*-----*
*----*--------*----*
*---*----------*---*
*--*------------*--*
*-*--------------*-*
**----------------**
********************
'''
Vowels and Consonants

The program must a string S as the input. The program must


print all the vowels in the string followed by all the
consonants in the string as the output.

Boundary Condition(s):
1 <= Length of S <= 200

Example Input/Output 1:
Input:
elephant

Output:
eealphnt

Explanation:
Here the vowels are "eea" and the consonants are "lphnt"
Hence the output is "eealphnt".

Example Input/Output 2:
Input:
HETEROGENEOUS

Output:
EEOEEOUHTRGNS
Template Strings Count

A template is a special string which can be used to generate multiple strings consisting of characters from the
template. For example, the template string ab can be used to generate strings ab, aba, bab, aabb, bbaa, babb,
bbaba and so on. N strings are passed as the input. The program must print the number of templates used in
generating the N strings.

Note:
All the characters from the template must be present in the generated string.
Template string must not have any repeated characters in it.
The order of the characters in template strings are ignored (i.e. abc is same as bca).

Boundary Condition(s):
1 <= N <= 100
1 <= Length of string <= 100

Input Format:
The first line contains N.
The second line contains N strings separated by space(s).

Output Format:
The first line contains the count of the templates used.

Example Input/Output 1:
Input:
5
abc abaa banana ban caba

Output:
3

Explanation:
The template string abc is used to generate the strings abc and caba.
The template string ab is used to generate the string abaa.
The template string abn is used to generate the strings banana and ban.
So there are three template strings used to generate the five strings.

Example Input/Output 2:
Input:
6
aaaa bbbb aa bbb red re

Output:
4

Input:
3
aa aaa a
Expected Output:
1
Trapezium Pattern Printing

Given an integer N as the input,print the pattern as given in the Example


Input/Output section

Input Format:
The first line contain N.

Boundary Conditions:
2<=N<=100

Example Input/Output1:
Input:
4

Output:
1*2*3*4*17*18*19*20
--5*6*7*14*15*16
----8*9*12*13
------10*11

Example Input/Output2:
Input:
7

Output:
1*2*3*4*5*6*7*50*51*52*53*54*55*56
--8*9*10*11*12*13*44*45*46*47*48*49
----14*15*16*17*18*39*40*41*42*43
------19*20*21*22*35*36*37*38
--------23*24*25*32*33*34
----------26*27*30*31
------------28*29

You might also like