Accenture
Accenture
Googly Number
Problem Statement
You are given a number N, your task is to check whether the number is GOOGLY or NOT
GOOGLY. A number is GOOGLY if the sum of digits of that number is prime.
Input Format:
Output Format:
Print the string denoting whether the number is GOOGLY or NOT GOOGLY..
Constraints:
1≤N≤10^9
Example:
Input:
21
Output:
GOOGLY
Explanation:
The sum of digits of 21 is 2+1-3, which is a prime number. Hence, the number is GOOGLY.
02. Battle of the Titan
Problem Statement
The first line contains two integers d and m-the titan's durability and the number of squads you
have...
The second line contains m integers a1,a2,...,am- the amount of damage each squad deals per
attack.
The third line contains mmm integers r1,r2,..., rm-the recovery time for each squad, indicating
how many turns they must wait before attacking again after an attack.
Input Format:
Output Format:
For each battle scenario, print the minimum number of turns required to defeat the titan. The
output will be matched to the candidate's output printed on STDOUT.
Constraints:
1≤d,m≤2×10^5
1≤ai≤2×10^5
1≤ri≤2×10^5
Problem Statement
Alex is a secret agent, and he intercepted some encoded strings sent by a rival organization.
Alex needs to decode these strings into numbers using a specific decoding rule. The decoding
rule converts each character in the string to its ASCII value and then uses positional weights to
form the final number.
For example:
Given n strings, help Alex decode each string according to this rule.
Input Format:
Output Format:
Problem Statement
Alex has an integer array arr of size N and needs to construct an alternating prime sequence
from the given set of integers for the coding challenge. For each integer in the array that he is
unable to use, his penalty increases by the amount of that integer value An alternating prime
sequence is defined as a sequence where each prime integer is followed by a non-prime integer
and each non-prime integer is followed by a prime one. For example, [1, 2, 4, 3, 6, 5] is
considered to be a valid alternating prime sequence while [1, 2, 3, 4, 5, 6] is not a 2 and 3 are
both primes. Note that 1 is considered to be a non-prime integer, Your task is to find and print
the minimum possible penalty that Alec can have while completing the task.
Input Format:
Each of the next N lines contains a single element denoting the elements of the array arr
Output Format:
Print the minimum possible penalty that Alex can have while completing the task.
Sample Input:
Sample Output:
Problem Statement
There are exactly N trees on a number line. Each tree stands at a unique integral point T[i].
Exactly M water sprinklers are also placed on the same number line, with each placed at a
unique integral point S[i]. A point can contain a tree as well as a water sprinkler. A water
sprinkler can provide water to the trees, which are not more than k units far in both directions
from the water sprinkler. If k=0, then the water sprinkler will only provide its water to the tree at
the same point. Your task is to find the minimum value of k such that all the trees receive water
from the water sprinklers
Input Format:
The input consists of four lines: The first line contains an integer N denoting the number of trees
on the number line.
The second line contains N space-separated integers, representing the positions of the trees on
the number line, denoted as T[1]. T[2],.... T[N].
The third line contains an integer M, denoting the number of water sprinklers on the number
line.
The fourth line contains M space-separated integers, representing the positions of the water
sprinklers on the number line, denoted as S[1], S[2]..., S[M].
Output Format:
Output a single integer k, which is the minimum value such that every tree receives water from
at least one sprinkler.
Sample Input:
146
35
Sample Output:
Problem Statement
You are given an array A consisting of N positive numbers. In one operation, you can take any
subarray of the array and replace it with its sum. You can perform this operation any number of
times. Your task is to print a number that denotes the maximum length of the non-decreasing
array after performing the above operations.
For example: If A: [1, 4, 2, 6, 9], you can choose the subarray [2.6] and replace it with its sum.
We get A: [1, 4, 8, 9]. Therefore in 1 operation, the array can be made non-decreasing.
Input format:
The second line contains N space-separated integers denoting the array elements.
Output Format:
Output a single integer denoting the maximum length of the non-decreasing array after
performing the operations.
Sample Input:
14269
Sample Output:
Problem Statement
You are given a string s. Your task is to modify and print the given strings in such a way that the
adjacent characters in the string don't repeat themselves more than twice.
Note:
You can delete the extra characters to ensure that the characters in the string don't repeat
themselves more than twice.
Input format:
The input consists of a single line:
Output format:
Print the modified string such that the characters in the string don't repeat themselves more than
twice.
The output will be matched to the candidate's output printed on the STDOUT.
Sample input:
aaabbc
Sample Output:
aabbc
Problem Statement
Alice climbs a staircase and takes N steps to reach the top. In each turn Alice can climb 1 or M
stairs. Find the minimum number of climbs to reach the top i.e. Nth stair.
Input Format:
Output Format:
Print the number that represents the minimum number of climbs required to reach the top.
The output will be matched to the candidate's output printed on the STDOUT.
Sample Input: 10 3
Sample Output:
Problem Statement.
The power of a number indicates how many times that number is multiplied by itself. You are
given an integer n, find whether n is the power of 2. If n is a power of 2, then print the power,
else print-1.
Input Format:
Output Format:
The output will be matched to the candidate's output printed on the STDOUT.
Constraints:0≤n≤10^9
Sample Input:
64
Sample Output:
Problem Statement
Elections are conducted in a town that has a population N. All the people of the town cast votes
on the various candidates in town. The people of the town later realized that the votes of only
the candidates 18 and above years of age should be considered. Find out the candidate who is
the winner if only the votes of age group 18 and above are considered. If the winner cannot be
decided or there is a tie, print-1.
You are given an array vote which represents the candidate to whom the vote is given by the i th
person and another array of age which represents the age of that particular voter.
Input Format:
The first line will contain one value N, the size of the arrays.
The second line will contain N space-separated integers representing the vote array
The third line will contain N space-separated integers representing the age array.
Output Format:
Print the candidate number who received the most votes from people aged 18 and above, If
there is a tie or no valid votes, print-1.
Sample Input:
12132
17 21 20 19 18
Sample Output:
Problem Statement
You are given a string str. Your task is to find the number of checks that is not satisfied by the
string str by checking the validation of the string str if it's a strong password or not. A password
is a strong password only if:
Input Format:
Output Format:
Print the number that represents the number of checks that is not satisfied by the str.
The output will be matched to the candidate's output printed on the STDOUT.
Sample input:
A1b@!cd
Sample Output:
Sample input:
aabbcc
Sample output:
4
12. STRING SHORTENING
Problem Statement
You are provided with string str and your task is to shorten the string to the minimum length
possible. The minimum length of the string can be attained by performing a set of operations
that states that you could select two same characters and delete them but without disturbing the
order in the string which means that only the adjacent same letters can be deleted. For
example, "baaab" can be reduced to "bab" in just one iteration. Your task is to shorten the length
of the string str and print the reduced string and if all the characters are deleted then print
"Empty String".
Input Format:
Output Format:
Print the modified string. If the modified string contains no character, then print" Empty String".
The output will be matched to the candidate's output printed on the STDOUT
Sample Input:
abba
Sample Output:
Empty String
Sample Input:
baaab
Sample Output:
Bab
13. KEYPAD STROKES
Problem Statement
The keypad shown below works as follows: To type "a", it requires a single stroke on the "2"
button, to type "b", it requires two strokes on the "2" button, to type "c", it requires three strokes
on the "2" button, to type "d", it requires a single stroke on the "3" button. It works the same way
for the other alphabets.
Input Format:
Output Format:
Print the total number of strokes required to type the given string.
Sample Input:
hello
Sample output:
13
14. TRUNCATE SEQUENCES OF BINARY NUMBERS
Problem Statement
Alex is working with sequences of binary strings. They are given a sequence of binary strings
and an integer k. Their task is to truncate the sequence such that it contains only the first k
binary strings. Alex needs your help to write a code that performs this task efficiently.
Input Format:
The first line contains a string s representing the sequence of binary strings, where each binary
string is separated by a space.
Output Format:
If k=0, print-1.
Otherwise, print the truncated sequence of binary strings containing the first k strings, each
separated by a space.
Sample Input:
Sample Output:
Problem Statement
You are given an integer array arr of size N. The elements of the array arr represent a number.
Your task is to rearrange and print the array elements such that after rearranging, the number
represented by the array arr gives the largest value.
Input Format:
Output Format:
The output will be matched to the candidate's output printed on the STDOUT
Sample Input:
3 30 34
Sample Output:
34 3 30