Zoho
Zoho
1. Given a number system that only uses the digits 3 and 4, the task is to find the Nth
number in this system.
Explanation:
In this number system, the numbers are generated using only the digits 3 and 4. The
sequence of numbers would look like this:
3, 4, 33, 34, 43, 44, 333, 334, 343, 344, ...
Constraints:
1 <= N <= 10^4
Test Case 1:
Input: n = 5
Output: 43
Explanation: The 5th number in the system is 43.
Test Case 2:
Input: n = 10
Output: 334
Explanation: The 10th number in the system is 334.
Constraints:
n == height.length
1 <= n <= 2 * 104
0 <= height[i] <= 105
Testcase 1:
Testcase 2:
Constraints:
s1.length == s2.length
1 <= s1.length <= 30
s1 and s2 consist of lowercase English letters.
Testcase 1:
Testcase 2:
If the sum of the digits is odd, remove all odd digits from the number.
If the sum of the digits is even, remove all even digits from the number.
Finally, print the modified number in word representation form.
Contraints:
The input should be in string.
It should contain only alphabets.
Testcase 1:
Testcase 2:
5. Write a C program that takes a sentence as input from the user. The sentence
should contain more than 15 words. For each word in the sentence, the program
should select the character with the maximum ASCII value and determine if it is a
consonent. If the maximum ASCII value character is a consonent, then print the word
along with the consonent character, otherwise ignore the word.
Contraints:
The input should be in string.
It should contain only alphabets.
Testcase 1:
Input:
naruto is a most popular anime. favourite characters are naruto, sasori, itachi,
kakashi, hinata and jiraya.
Output:
is - s
most - t
anime - n
characters - t
are - r
sasori - s
itachi - t
hinata - t
and - n
jiraya - y
Testcase 2:
Input:
akatsuki is the group of rogue shinobies. sasori, deidara, kakuzu, hidan, itachi,
kisame, tobi, zetsu, pain and konan.
Output:
is - s
the - t
shinobies - s
sasori - s
deidara - r
kakuzu - z
hidan - n
itachi - t
kisame - s
tobi - t
zetsu - z
pain - p
and - n
konan - n
6. Alice is texting Bob using her phone. The mapping of digits to letters is shown in
the figure below.
In order to add a letter, Alice has to press the key of the corresponding digit i times,
where i is the position of the letter in the key.
For example, to add the letter 's', Alice has to press '7' four times. Similarly, to add
the letter 'k', Alice has to press '5' twice.
Note that the digits '0' and '1' do not map to any letters, so Alice does not use them.
However, due to an error in transmission, Bob did not receive Alice's text message
but received a string of pressed keys instead.
For example, when Alice sent the message "bob", Bob received the string
"2266622".
Given a string pressedKeys representing the string received by Bob, return the total
number of possible text messages Alice could have sent.
Testcase 1:
Testcase 2:
7. Ajay has a flight to catch in an hour. So he has to reach the airport as fast at
possible. He hires a taxi and promises the taxi driver that if he reaches the airport
within k minutes he would pay the taxi driver double the amount.
The taxi is at point 0,0 & airport is at (n-1,m-1) in a 2 – D grid of n rows and m
columns. The grid has some blocked (represented as’#’) and some unblocked
(represented as’.’) cells.
The starting position of the taxi is in the top – left corner of the grid. It is guaranteed
that the starting position & ending positions are not blocked. Each cell of the grid is
connected with its right ,left,top,bottom cells (if those cells exist ). It takes 1 second
for a taxi to move from a cell to its adjacent cell.
If the taxi can reach the bottom-right (airport) corner of the grid within k seconds,
return the string ‘Yes’. Otherwise , return the string ‘No’.
Constraints
1<_rows<_500
0<_maxTime<_10^6
Testcase 1
..
3 -> maxTime = 3
Sample Output
Yes
Explanation
The grid has 2 rows and 2 columns and the time within which the taxi needs to reach
the bottom-right cell in 3 seconds. Starting from the top-left cell, the taxi can either
move to the top-right unblocked
Testcase 2:
rows =3
grid =[‘..##’,’#.##’,’#…’]
maxTime =5
..##
#.##
#…
It will take the taxi 5 seconds to reach the bottom right corner. As long as k>_5,return
‘Yes’.
Returns:
8. You are given a 0-indexed integer array nums, where nums[i] is a digit between 0
and 9 (inclusive).
The triangular sum of nums is the value of the only element present in nums after the
following process terminates:
Testcase 1:
Testcase 2:
9.The problem is to find the number of groups in a given array where the sum of the
elements in each group is divisible by a given number X, and the group size is
limited to a range of X numbers.
Constraints :
Testcase 1:
Input:
Array: 3, 9, 7, 4, 6, 8
X: 3
Output:
3, 9
3, 6
9, 6
3, 9, 6
No of groups: 4
EXPALANATION :
To find the sum of the elements in the groups and that sum should be divisible by
input X and the groups should be limited to range with X numbers.
If X is 3, then the group should have only 2 elements and 3 elements from the array
whose sum is divisible by 3.
If X is 3, then the group should have only 2 elements and 3 elements from the array
whose sum is divisible by 3.
Testcase 2:
Input:
Array: 5, 10, 15, 20, 25, 30
X: 5
Output:
5, 10
5, 15, 25
10, 15
10, 20, 30
15, 20
20, 25
25, 30
Number of groups: 7
Explanation:
The given array is ``, and the value of X is 5.
The program should find all possible groups where the sum of the elements in the
group is divisible by 5, and the group size is limited to a range of 5 numbers.
The output shows the different groups that satisfy the given conditions.
The first group is ``, where the sum is 15, which is divisible by 5.
The second group is ``, where the sum is 45, which is divisible by 5.
The third group is ``, where the sum is 25, which is divisible by 5.
The fourth group is ``, where the sum is 60, which is divisible by 5.
The fifth group is ``, where the sum is 35, which is divisible by 5.
The sixth group is ``, where the sum is 45, which is divisible by 5.
The seventh group is ``, where the sum is 55, which is divisible by 5.
The total number of groups found is 7.
10. Martha is a very bright student. She loves solving high-level puzzles. She has a
list of ‘N’ puzzles. Each puzzle has some difficulty level. There is a rule that one can
only solve a puzzle with difficulty ‘X’ if she has already solved all the puzzles with
difficulty less than ‘X’. She can’t wait to get a puzzle having a difficulty level higher
than the current puzzle.
Your task is to tell Martha how long she has to wait to get a puzzle having a higher
difficulty level than the current puzzle. If there is no puzzle ahead with a higher
difficulty level, just print "0".
For Example :
Let ‘N’ = 5 and ‘PUZZLE’ = [ 30, 40, 80, 50, 70 ]
After solving the first puzzle, the very next puzzle has a difficulty level 40 and 40 >
30.
Then after 40, the very next puzzle has a difficulty level 80 and 80 > 40.
But for 80, there is no puzzle having a difficulty level greater than 80.
For 50, the very next puzzle has a difficulty level 70 and 70 > 50.
Again for 70, there is no puzzle having a difficulty level greater than 70.
Testcase 1:
Sample Input 1 :
2
8
31 56 30 33 32 90 60 54
1
50
Sample Output 1 :
14121000
0
Explanation
For Sample Input 1 :
The first test case for 31 next increasing difficulty = 56 (index diff = 1).
For 56 next increasing difficulty = 90 (index diff = 4).
Similarly, check for 30,33, and 32.
For, 90,60, and 54 there are no greater elements.
In the second test case, there is only one puzzle, so the answer will be zero.
Testcase 2:
Sample Input 2 :
2
5
90 80 70 60 50
5
50 60 70 80 90
Sample Output 2 :
00000
11110