Technical coding
Technical coding
1. In a tech startup, the team faced a software bug, the zeros in their data
outputs were causing their system to crash. A junior developers suggested
replacing all the zeros with 5's as quick fix. By implementing this single code
weak.they stabilized the system. Your task is to find and return an integer
value representing value that stabilized the system.
Input specification
Input1: An Integer Value
Output specification
Return an integer value representing the value that stabilized the system.
Example 1 :
Input 1: 100067
Output1: 15567
Example 2:
Input 2: 892
Output2 : 892
Explanation : In this given input there is no zero so return the same number as
output.
#include <stdio.h>
return result;
}
int main() {
int input1;
scanf("%d",&input1);
int output1 = stabilizeSystem(input1);
printf("%d", output1); // Output1: 15567
return 0;
}
2. You are given a string S, which contains the moves played by two players
sequential in a game called Snake Water Gun. The rules of the games are as
follows.
Snake beats water, water beats gun and Gun beats snake.
The moves played by player A and the player B in the first round will be
stored in the string as snakewater.
Similarly, in second round, the moves will be stored in the string as
“snakewatergunsnake”.
There are N rounds that are played in the game and your task is to find and
return an integer value representing how many rounds player A will win.
Note: The given string is as lowercase.
Input specification
Input 1: An integer Value N representing the number of rounds.
Input 2: A String S, representing the moves played by the two players.
Output Specification:
Return an Integer value representing how many rounds Player A wins in the
game.
Example 1:
Input 1: 3
Input 2: watergunwaterwatergunwater
Output 1: 1
Explanation:
Here we are given that 3 rounds are played by the two players and their moves
are “watergunwaterwatergunwater”. So, the result of each round are given in
the following manner.
1. First Round - Player A shows “water” and player B shows “ gun”. As water
beats gun,player A win this round.
2. Second Round - Player A shows “water” and player B shows “water”. which
results in a draw.
3. Third Round- Player A shows “ gun” and player B shows “water”. As water
beats gun, player B wins this round.
Repeat String
4. You are given an integer N and a string S. Your task is to find and return a
new string which consists of the original string repeated N times.
Input Specification
Input 1: An Integer value N
Input 2: A string value S
Output Specification :
Return a new string which consists of the original string repeated N times.
Example 1:
Input 1: 3
Input 2: abc
Output : abcabcabc
Explanation:
Here the original string is “abc” . When repeated 3 times. We will get
“abcabcabc” as the required new string. Hence “abcabcabc” is returned as
output.
Example 2:
Input 1: 5
Input 2: xyz
Output: xyzxyzxyzxyzxyz
Chocolate Types
5. Monica went to a confectionery shop which has N different types of
chocolates. The shop displays a price chart, where column T represents the
types of chocolate and P represent their respective price.
She was asked to pick K different types of chocolate at the minimum possible
cost . Your task is to find and return as an integer value representing the total
amount of money she will spend. Return -1 if K types of chocolates cannot be
chosen.
Input Specification :
Input 1: An integer value N representing the number of chocolate types.
Input 2: An integer value K representing the number of types of chocolates to
buy.
Financial Dataset
6. You are working on a financial analyzing tool which represents the daily
stock price of company over a time. Each element in an Integer array A of size
N represents the closing price of stock for a particular day. Your task is to find
and return an Integer value representing the total number of days where the
stock price decreased . indicating negative growth.
Input Specification:
Input 1: An integer array A containing the closing price of the stock.
Input 2: An integer value N representing the size of the array.
Output Specification:
Return an integer value representing the total number of days which the stock
price decreased, indicating negative growth.
Example 1:
Input 1: {3,5,6,-7,9,10,-12}
Input 2: 7
Output : 2
Output: 3
Explanation : Here A={-5,-8,-12} the stock price decreased at -5,-8,and -12.
Therefore 3 will be the returned as output.
Input Specification:
Input 1: An integer value X
Input 2: An integer value Y
Output Specification:
Return an integer value representing the product of the two integer in the 12
hour system.
Example 1:
Input 1: 4
Input 2 : 5
Output : 8
Explanation :
Here x=4 and y=5 and their product is 20. Therefore 8 is returned as the
output in 12 hour system.
Example 2:
Input 1: 2
Input 2: 5
Output: 10
Explanation :
Here x=2 and y=5 and their product is 10. Therefore 10 is returned as the
output in 12 hour system.
Refueling Vehicles
8. You are incharge of a convoy of N vehicles, each with fuel meter which
shows the fuel present in each vehicle in litre. Each vehicles need to travel a
distance of X kilometers. If the fuel becomes empty before reaching X
kilometers the vehicle can refuel but the refueling will be of X litre and if the
vehicles completes the X kilometers where fuel is left then the extra fuel will
be given to next vehicle in the convoy. You must rearrange the convoy such
that the vehicles takes minimum refueling stops.
Your task is to find and return an Integer value representing the minimum
number of refueling stops required by the convoy of vehicles.
Note :
The vehicles can go 1 kilometer in a single litre
The refueling at any point of time will be for X Litre.
Canopy Area
Explanation : Here A={3,5,6,-7,9,10,-12} the stock price decreased at -7 and -
12. Therefore 2 be the returned as output.
9. You are developing a feature for an environmental awareness app that helps
users to know how much area their tree’s shadow covers. You have the
distance D from a tree’s trunk to the edge of the shadow. Your task is to
calculate and return an integer value representing the shadow area of canopy.
Input Specification :
Input 1: An integer value D representing the distance from the tree trunk to
the edge of shadow.
Output Specification
Example 1:
Input 1: 5
Output 1: 78
Explanation:
Here D=5. So, area of the canopy would be 3.14 * 5*5=78.5 therefore 78 will
be returned as output.
Example 2:
Input 1: 7
Output : 154
Explanation:
Here D=7. So, area of the canopy would be 3.14 *7*7 =153.86 therefore 154
will be returned as output.
Rebound Height
10. Rahmat has a ball. He wants to find the ball’s rebound height, which he
dropped from height H and initial velocity V , After the Nth rebound the final
velocity of the ball is Vn. Your task is to help him find and return an integer
value representing the height to which the ball rebounds after N bounces.
Note:
H= H * e2n where H is the rebound height, H is the initial, e is the
coefficient of restitution and is the number of bounces.
En = V/Vn Where V is the intial velocity and Vn is the final velocity.
Input Specification :
Output Specification:
Return an integer value representing the height to which the ball rebounds
after N bounces.
Example 1:
Input 1 :10
Input 2 : 20
Input 3 : 5
Output : 160
Explanation :
Here H is 10, V is 20 and Vn is 5. Now en is V/Vn is 20/5=4 and H=10* 42 =160.
Therefore , 160 is returned as the output.
Qualifying Chances
11. You are given an integer N, representing the number of matches, an
integer M representing the maximum warning margin, an integer R ,
representing the required run rate for qualification and an integer array W,
representing the warning margins of previous matches(N-1) played by them.
Your task is to find and return an integer value representing the minimum
number of runs by which a team should win the last match to qualify for the
playoffs. Return -1 if qualification is not possible.
Input Specification
Input 1: An integer value N representing the number of matches a team can
play in the tournament.
Input 2: An integer value M , representing the maximum margin by which a
team can win in the tournament
Input 3: An integer value R , representing the required run rate which the team
must have at the end of the league stages to qualify for the playoffs.
Input 4: An integer array W , representing the warning margin of all the
matches a team has played till now in the tournament.
Output Specification
Return an integer value representing the minimum number of runs by which a
team should win the last match to qualify for the playoffs. Return -1 if
qualification is not possible.
Input 1: 4
Input 2: 20
Input 3: 9
Input 4: {10,0,9}
Output: 17
Explanation:
Here, we are given N=4, M=20, R=9 and the wining margins of all the matches
the team has played till now are {10,0,9} . If the team wins by 17 runs in the
final match. Its average run rate will become 9 ((10+0+9+17)/4), which means
the qualification criteria, so , 17 is returned as the output.
Coding questions
1. Question 2
How to Attempt?
Island Life
You are stuck on an island where they sell and eat coconut sweets only. A
person can buy at most 1 box per day with each box containing N pieces.
To remain alive, you must consume E coconut sweets daily for D days, but
the catch is that you cannot purchase sweets on Sundays. Your task is to
find and return an integer value representing the minimum number of
times you have to buy coconut sweets in order to stay alive. If not
possible, return -1.
Note: The day starts from Monday
Input Specification:
input1: An integer value N, representing the number of coconut sweets
per box. input2: An integer value E, representing the number of coconut
sweets you must eat daily. input3: An integer value D, representing the
number of days you have to spend on the island.
Output Specification:
Return an integer value representing the minimum number of times you
have to buy coconut sweets in order to stay alive. If not possible, return -
1.
2. How to Attempt?
Array Multiplication
Henry has 2 arrays A and B each of a given equal length N. He wants to
find the summation of the array after element-wise product and wants
your help. Your task is to help him find and return an integer value
representing the sum of the elements obtained after element-wise
multiplication of the arrays.
Input Specification:
input1: An integer array A input2: An integer array B input3: An integer N,
representing the length of the arrays
Output Specification:
Return an integer value representing the sum of the elements obtained
after element-wise multiplication of the arrays.
Example 1:
input1: (1, 2, 3) input2: (4, 2, 3) input3: 3
Output: 25
4) Island Life
You are stuck on an island where they sell and wat coconut sweets only. A person can buy at
most 1 box per day with each box containing N pieces. To remain alive, you must consume E
coconut sweety daily for D days, but the catch a thar purchase sweets on Sundays. Your task
is to find and return an integer value representing the minimum number of times you have
to buy coconut sweets in order to stay alive. If not possible, return-
Input Specification:
1. Input: An integer value N, representing the number of coconut sweets per box.
2. input: An integer value L, representing the number of coconut sweets you must eat
daily
3. Input: An integer value representing the number of days you have to spend on the
island,
Output Specification
Return an integer value representing the minimum number of times you have to by coconut
sets in order to stay alive. If not possible return-1
Constraints:
1 ≤ N, L, D ≤ 1000
Example:
Example 1:
Input:
o N = 10
o L=2
o D = 10
Output: 5
Explanation:
You need 2 coconut sweets per day for 10 days, so you need a total of 2 * 10 = 20
coconut sweets.
Each box contains 10 sweets. To get 20 sweets, you need to buy at least 20 / 10 = 2
boxes.
There are 10 days, including 1 Sunday. So, you can only buy sweets on 9 days.
Since you need 2 boxes and can buy only 1 box per day, you can manage by buying a
box on any 2 of the 9 days (excluding Sunday).
Example 2:
Input:
o N=5
o L = 10
o D=6
Output: -1
Explanation:
You need 10 coconut sweets daily for 6 days, so you need 10 * 6 = 60 sweets.
5) Array Multiplication
Henry has 2 arrays A and B each of a given equal length N. He wants to find the summation
of the array after element-wise product and wants your help. Your task is to help him find
and return an integer value representing the sum of the elements obtained after element-
wise multiplication of the arrays.
Input Specification:
input1: An integer array A
input2: An integer array B
input3: An integer N, representing the length of the arrays
Output Specification:
Return an integer value representing the sum of the elements obtained after element-wise
multiplication of the arrays.
Example 1:
input1: (1,2,3)
input2: (4.2.3)
input3:3
Output: 17
Explanation:
Element-wise multiplication of arrays A and B:
o 1*4=4
o 2*2=4
o 3*3=9
The sum of these products is 4 + 4 + 9 = 17.
o input1 = 3
o input2 = 4
Output: 12
Explanation:
The product of X and Y is 3 * 4 = 12.
7) Financial Dataset
You are working on a financial analysing tool which represents the daily stock prices of a
company over a time. Each element in an integer array A of the size N represents closing
price of the stock for a particular day. Your task is to find and return an integer value
representing the total number of days where the stock pour deed indicating negative
growth.
Input Specification:
input1: An integer array A containing the closing price of the stock
input2: An integer value N representing the size of array
Output Specification:
Return an integer value representing the total number of days where the stock price
decreased, indicating negative growth
Example 1:
input1: (3.5.6-7.9.10-12)
input2: 7
Output: 2
Explanation:
835 Here, A= (3,5,6, -7,9,10, -12). The stock price decreased at -7 and -7 Therefore, 2 will be
returned as output.
Example 2:
input1: (-5, -8, -12)
input2:3
Output: 2
Explanation:
The stock price decreased at -8 (from -5 to -8) and at -12 (from -8 to -12).
8) You are given a function that needs to convert specific symmetrical digits in a string to their capitalized
alphabetical form within a given range of positions. The function should handle cases where the start and end
positions are invalid or out of bounds.
Task: Write or correct the function that performs the following:
1. Convert Digits to Words: Convert the digits in the specified range of the string to
their corresponding capitalized word forms (e.g., 8 becomes EIGHT).
2. Position Validation:
o If start_position is greater than end_position, return "INVALID".
o If start_position is less than 1, return "INVALID".
o If end_position exceeds the length of the input string, return "INVALID".
Details:
The start position is 1-based, meaning start_position = 1 refers to the very first
character of the string.
Each digit should be treated individually, so 10 would be converted to "ONEZERO".
Input Specification:
1. input_str: A string that may contain digits, letters, and special characters.
2. start_position: An integer representing the starting position for conversion.
3. end_position: An integer representing the ending position for conversion.
Output Specification:
Return the modified string after conversion if valid.
Return "INVALID" if any of the conditions for invalid positions are met.
Example:
Example 1:
Input:
Starting at position 16 and ending at position 18, the digits 888 are converted to
EIGHTEIGHTEIGHT.
The rest of the string remains unchanged.
2) How to Attempt?
Magical Number
You are given a program to find the count of magical numbers from 1 to N. A magical
number is defined by the following criteria
Convert each number in the range 1 to N (inclusive) to its binary representation.
Replace '0' with '1' and '1' with '2' in the binary string
Calculate the sum of the digits in the modified binary string. I the resultant number is
odd, then it is considered a magical number.
Your task is to find and return an integer value representing the count of the magical
numbers present within the given range
Input Specification:
input1: An integer N representing the upper limit of the range (1 to N).
Output Specification:
Return an integer value representing the count of magical numbers in the range
from 1 to N.
Example:
Example 1:
Input: N = 5
Output: 2
Explanation:
Convert each number from 1 to 5 into binary:
Example:
Example 1:
Input:
o N=3
o S = "snakewatersnakegunwatersnake"
Output: 2
Explanation:
Round 1: Player A = "snake", Player B = "water" → Player A wins (Snake beats Water)
Round 2: Player A = "water", Player B = "gun" → Player A wins (Water beats Gun)
Round 3: Player A = "snake", Player B = "snake" → Draw (no one wins)
Player A wins 2 out of 3 rounds, so the output is 2.
1)Even Sum
You are organizing a charity run where participants contribute a dollar for every
even-numbered kilometer they complete. Your task is to find and return an integer value representing the
total amount of money raised if the race is N km long.
Input Specification:
Input1: An integer value N
Output Specification:
Return the sum of all even numbered kilometers till N they complete.
Example 1:
Input1: 10
Output: 30
2)Product Pair
You are given an integer array A of length N and your task is to find and return an 2009 integer value
representing the count of unique pairs whose products are multiples of 3.
Note: A Unique pair means that the elements must be the same regardless of their order For instance, (1,3)
and (3.1) are considered as the same pair
Input Specification:
Input1: An integer value N, representing the size of the array
input2: An integer array A
Output Specification:
Return an integer value representing the count of unique pairs whose products are multiples of 3.
Example 1:
Input1:4
input2: (3.6.5.4)
Output: 5
3)Magical Number
you are given a program to find the count of magical numbers from 1 to N .A magical number is defined by the
following criteria
Convert each number In the range 1 to N (inclusive) to its binary representation
Replace ‘0’ with “1’ and ‘1’ with ‘2’ in the binary string.
Calculate the sum of the digits in the modified binary string. If the Resultant number is odd,
then it is considered a magical number.
Your task is to find and return an integer value representing the count of the magical numbers present within
the given range.
Input Specification:
Input1: An integer value N representing the range of numbers.
Output Specification:
Return an integer value representing the count of magical numbers present within the range.
4)Minimum Badness
You are given a string S representing the colours of houses (red(R), blue(B) or white(W)). The badness value is
the number of differently-coloured adjacent houses. You can paint the white houses red or blue to minimize
the badness value. Your task is to find and return an integer value representing the minimum possible badness
3 value.
Input Specification:
Input1: A string value 5, representing the colours of houses.
Output Specification:
Return an integer value representing the minimum possible badness value.
Example 1:
Input1 : RRWBWBW
Output: 1
6)SUPERMARKET SALES
This question accounts for 25% of the total test. Please do not forget to submit your answer, timed-out tests
will result in 0 points awarded.
GIVEN
Given A, the unique integer prices of N items in a supermarket. A large number of customers enter the
supermarket with the target of buying a basket of items of total price B. The customers can take more than
one of the same item. Given that all possible baskets of items with a total price of B have been sold exactly
once, find how many baskets in which the Mth item has been sold.
NOTE
• The order of the items in the basket will not matter.
Ex: basket₁ = (item1, item2), basket2 = (item2,item₁)
then, basket1=basket2
7)What will be the output of the given pseudo code?
Integer j
Integer arr[2][2]= {{3, 1}, {1, 2}}
arr[1][1]=(arr[0] [1]+arr[1] [0])+arr[0][0])
if((arr[1][0]&arr[0] [0]&arr[1][0])<(4+arr[1][0]+2))
arr[1][0]=arr[1] [0]+arr[0][0]
End if
arr[1][0]=(arr[1] [0]+arr[1][0])+arr[0][0]
Print arr[1] [0]+arr[0] [0]
Note- &: bitwise AND – The bitwise AND operator (&) compares each bit of the first operand to the
corresponding bit of the second operand. If both bits are 1, the corresponding result bit is set to 1.
Otherwise, the corresponding result bit is set to 0.
Options
3.0
12.0
8.0
16.0
b= (a + b) &c
if((9 – b + c) > (c + a))
c=a^a
End if
End if
c=c+c
Print a+b+c
Note- &&: Logical AND – The logical AND operator (&&) returns the Boolean value true (or 1) if both operands
are true and returns false (or 0) otherwise.
&: bitwise AND – The bitwise AND operator (&) compares each bit of the first 20 operand to the corresponding
bit of the second operand. If both bits are 1, the corresponding result bit is set to 1. Otherwise, the
corresponding result bit is set to 0.
Options
30.0
34.0
33.0
43.0
b = (586) ^ a
End for
Print a + b
Note- & bitwise AND – The bitwise AND operator (&) compares each bit of the first operand to the
corresponding bit of the second operand. If both bits are 1, the corresponding result bit is set to 1. Otherwise,
the corresponding result bit is set to 0.
^is the bitwise exclusive OR operator that compares each bit of its first operand to the corresponding bit of its
second operand. If one bit is 0 and the other bit is 1, the Corresponding result bit is set to 1. Otherwise, the
corresponding result bit is set to 0.
Options
24.0
11.0
-12.0
6.0
10)Chocolate Types
Monica went to a confectionery shop which has N different types of chocolates. The shop displays a price
chart, where column T represents the types of chocolate and column P represents their respective prices.
She was asked to pick K different types of chocolates at the minimum possible cost. Your task is to find and
return an integer value representing the total amount of money she will spend. Return -1.
Note: She can buy only 1 chocolate of each type.
Input Specification:
Input1: An integer value N, representing the number of chocolate types
Input2: An integer value K. representing the number of types of chocolates to buy
Input3: An integer array representing the types of chocolates T
Input4: An integer array representing the prices P
Output Specification:
Return an integer value representing the total money she will spend. Retum -1, if K types of chocolates
cannot be chosen.
11)Repeat String
You are given an integer N and a string S. Your task is to find and return a new string which consists of the
original string repeated N times.
Input Specification:
Input1: An integer value N
Input2: A string value 5
Output Specification:
Return a new string which consists of the original string repeated N times.
Example 1:
Input1:3
Input2: abc
Output: abcabcabc
12)What does the following pseudocode line represent?
While(temperature > 100)
Options
Options
8
7
9
10
18)What is the term for a chart that illustrates the flow of functions or
processes without displaying any actual code?
A fiowchart
Structure chart
Both A and B
None
19)read the flowchart given below and answer the question that flows
If the fine paid for speeding was Rs 14000,which of the following could have been the speed?
Options
128 km/hr
136km/hr
159 km/hr
170 km/hr
20)A ship needs to transport a certain number of people from Point A to Point B. The capacity of the ship is
denoted by an integer C. and the total number of people to be transported is denoted by an integer N. Your
task is to find and return the number of rounds the ship needs to make in order to transport all the people
from Point A to Point B
Note : One round consists of the ship travelling from Poire & to Point & and then returning to Point A
Input Specification:
Output Specification
Return an integer value representing the number of rounds the ship needs to make.
Example 1:
Input: 50
Input2:200
Output:4
Question 21
Stabilize the system
In a tech startup, the team faced a software bug the zeros in their data outputs were causing their system to
crash. A junior developer suggested replacing all the 0 's with 5's as a quick fix. By implementing this simple
code tweak, they stabilized the system. Your task is to find and return an integer value representing the value
that stabilizes the system.
Input Specification:
Output Specification:
Return an integer value representing the value that stabilizes the system
Example 1 :
input1: 100067
Output: 155567
Question 3:
int array[] = {4, 5, 8, 9, 2);
int *ptr = (int*)(&array + 1);
9
QUESTION 22:
For a pipelined processor architecture if the following is the time taken for each stage of every process is
(5,2,4,8,3) ms respectively, what is the ratio of the turnaround time of the pipelined processor to non-
pipelined processor?
O 0.6
Ο 1/22
Ο 1.818
Ο 0.55
QUESTION 23 :
What is the output of the following code?
#include <stdio.h>
#include <stdint.h>
int main()
{
uint8_t a, max;
B. 256
C. 255
D. Infinite Loop
QUESTION 24 :
Mango Distribution
Given a number of mangoes and number of persons. Find the number
distribute identical mangoes among identical persons.
Input Specification:
Output Specification:
persons.
Example 1:
input1: 2
input2: 2
Output: 3
QUESTION 25 :
What will be the output of the following pseudocode?
1. Integer a,b,c
2. Set a = 6 b = 8 c = 10
3. For (each c from 2 to 4)
4. b = (2 + 5) + a
5. if ((8 + 3) < (6 + b))
6. b = b + b
7. a =10&&c
8.Else
9.jump out of the loop
10.End if
11. a = (B + 7) + c
12. End for
13. Print a + b
a. 88
b. 74
C. 59
D.69
QUESTION 26:
What will be the output of the given pseudo code for a=2 b=7, and c=6?
1.Integer funn (Integer a, Integer b, Integer c)
2 b=(c^8)+c
3 for(each c from 4 to 7)
4 b=(c+11)&b
5 a=11&a
6 End for
7 return a+b
Note- & bitwise AND- The bitwise AND operator (&) compares each bit of the first operand corresponding bit
of the second operand. If both bits are Otherwise, the corresponding result bit is set to 0. 1, the 188P
Corresponding result to the bit is set to 0.
is the bitwise exclusive OR operator that compares each bit of its second operand. If one bit is 0 and the other
bit is 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0.
QUESTION 27 :
Alice and song
Alice has a collection of songs represented as a string 5 where each character represents a song. A playlist is a
substring of the given string with exactly K number of songs. She wants to create a playlist that contains
maximum number of her favourite song which is 'a'. Your task is to find and return an integer value
representing the maximum number of favourite songs that she can get in a single playlist.
Input Specification:
Output Specification:
Return an integer value representing the maximum number of favourite songs that she can get in a single
playlist.
Example 1:
input1: abaca
input2 : 3
Output: 2
Example 2:
input1: bcdefgfedcb
input2:5
Output: 0
QUESTION 28 :
What will be the output of the given pseudo code?
1 Integer a,b,c
2 Set a=5, b=3, с=б
3.b-(c&b)+b
4.for(each c from 2 to 4)
5.b=(5&6)^a
6 End for
7.print a+b
Note- & bitwise AND-The bitwise AND operator compares each bit of the first operand to the corresponding
bit of the second operand .If both bits are 1,the corresponding result bit is set to 1. Otherwise, the
corresponding result bit is set to 0.
^ Is the bitwise exclusive OR operator that compares each bit of the first operand to the corresponding bit of
its second operand. If one bit is 0 and the other bit is 1, the corresponding result bit is set to 1.Otherwise, the
corresponding result bit is set to 1
b. 11.0
c. -12.0
d. 6.0
QUESTION 29 :
FIND LETTERS
Your friend gives you a string S which contains the name of a person and asks you to find the first and last
letter of their name. Your task is to find and return a string representing the first and the last letter.
Note:
• The output should be two capital letters with a dot separatory het
The output is case sensitive
Input Specification:
Output Specification:
Example 1:
. Canopy Area
You are developing a feature for an environmental awareness app that helps
users to know how much area their tree's shadow covers. You have the distance
D from a tree's trunk to the edge of the shadow. Your task is to calculate and
return an integer value representing the shadow area of the canopy.
Input Specification:
input1: An integer value D, representing the distance from the tree trunks
to the edge of shadow.
Output Specification:
Example 1:
Input: 5
Output: 78
17 . Assume that the following code snippet is used to encrypt and decrypt
messages. Identify the incorrect statement about the functioning and security of
this implementation:
Options:
The private key is kept secret and used for decryption and signing,
ensuring only the intended recipient can decrypt the ciphertext.
The public key is used to encrypt messages and verify signatures,
allowing secure communication without prior key exchange.
The use of RSA with OAEP padding and SHA-256 ensures the encrypted
message is secure against known cryptographic attacks.
The private key serialization and encryption ensure that the public key
cannot be compromised during storage or transmission.
18 . Vowel Permutation
You are given a string S and your task is to find and return the count of
permutations formed by fixing the positions of the vowels present in the string.
Note:
Input Specification:
input1: A string S
Output Specification:
Example 1:
Input: ABC
Output: 2
Explanation:
Here, in the given string "ABC" there is 1 vowel (A) and by fixing its position
there are 2 permutable letters (B, C). So, its permutation is 2! = 2. Therefore, 2
is returned as the output.
Example 2:
Input: CDF
Output: 6
Explanation:
Here, in the given string "CDF" there is no vowel and there are 3 permutable
letters (C, D, F). So, its permutation is 3! = 6. Therefore, 6 is returned as the
output.