Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
232 views13 pages

Zoho Round 2 - Set 16-28

Uploaded by

fanep97171
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)
232 views13 pages

Zoho Round 2 - Set 16-28

Uploaded by

fanep97171
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
You are on page 1/ 13

ZOHO SET 2

1.Given an odd length word which should be printed from the middle of the word.
Input: PROGRAM
Output:
G
GR
GRA
GRAM
GRAMP
GRAMPR
GRAMPRO
2. It is a program to implement Least Recently Used (LRU) concept.
3. Given a few pairs of names in the order child, father. The input is a person name and
level number. The output should be the number of children in that particular level for the
person given.
Example:
Input:
[
{Ram, Syam},
{Akil, Syam},
{Nikil, Ram},
{Subhash, Ram},
{Karthik, Akil}
];
4. Given an array of positive integers. The output should be the number of occurrences of
each number.
Example:
Input: {2, 3, 2, 6, 1, 6, 2}
Output:
1–1
2–3
3–1
6–2
SET 2
1. Adding 2 numbers
Given 2 huge numbers as separate digits, store them in array and process them and
calculate the sum of 2 numbers and store the result in an array and print the sum.
Input:
Number of digits:12
928135673116
Number of digits:9
784621997
Output :
9 2 8 9 2 0 2 9 5 1 1 32.
2.Given sorted array check if two numbers sum in it is a given
value
Input
Array = {1 3 4 8 10 } N = 7
output
true
3.Compiuting value of sin (x)
Input x = 30 n = 10
output = 0.5
Hint : The equation sin(x) = x – x^3 / 3! + x^5 / 5! – ….
4. Write function to find multiplication of 2 numbers using +
operator You must use minimum possible iterations.
Input: 3 , 4
Output 12
5. Given array find maximum sum of contiguous sub array
{-2 -3 4 -1 -2 1 5 -3}
output 7 elements [ 4 -1 -2 1 5]
6. Given unsorted array find all combination of the element for a given sum. Order should
be maintained.
Input :
8 3 4 7 9 N=7
Output
{3 4 } {7}
7. Write a program to determine whether a given number can be expressed as sum of two
prime numbers or not.
For example 34 can be expressed as sum of two prime numbers but 23 cannot be.
8. Take a 2 or 3 digit input number, reverse it and add it to the original number until the
obtained number is a palindrome or 5 iterations are completed.
Input : n = 32
Output : 55
23 + 32 = 55 which is a palindrome.
Input : 39
Output : 363
9. Given a string, reverse only vowels in it; leaving rest of the string as it is.
Input : abcdef
Output : ebcdaf
10. Write a program to check if the given words are present in matrix given below. The
words can be left to right, top to bottom and the diagonals (in top to bottom direction)
11. Write a program to form lines using given set of words. The line formation should
follow below rules.
i) Total characters in a single line excluding the space between the words and the favorite
character should not exceed the given number.
ii) Favorite character is case insensitive.
iii) Words should not be broken up. Complete words alone should be used in a single line.
A word should be used in one line only.
Input : Max char per line = 10
Favorite character = 'o'
Words : Zoho, Eating, Watching, Pogo
Loving, Mango
Output : Watching Zoho
Eating Mango
Loving Pogo

SET-3

1) Find the minimum number of times required to represent a number as sum of squares.
12 = 1^2 + 1^2 + 1^2 + 1^2 + 1^2 + 1^2 +
1^2 + 1^2 + 1^2 + 1^2 + 1^2 + 1^2
12 = 2^2 + 2^2 + 2^2
12 = 3^2 + 1^2 + 1^2

Input: 12
Output: min: 3
2) Search a string in a given 2D matrix. And print its possible path.
allowed movements are right left up and down.
3) In a given pascal triangle find the possible triangles.
4) in a matrix find the number of rectangles filled with 1s.
Input: 0 1 1 0
1110
0011
0011
Output: 2.
5) There are n items each with a value and weight. A sack is filled with the weights. In
other words there is an array with of length n having the values of the items arr[0…n-1] and
another array with weight arr[0…n-1].
if a sack is to be filled with weight W find the minimum possible value subset.

SET-4

1. Find the maximum of three numbers?


2. Print the total number of odd and even digits in the given number.
Ex. Input: 1234567
Output: ODD 4
EVEN 3
3. Find the second maximum among the given numbers.
Ex. INPUT:
Size of Array: 8
Enter the elements : 2 5 1 6 2 6 7
OUTPUT:
7
Ex. INPUT :
Size of Array : 4
Enter the elements : 4 1 2 2
OUTPUT : 2
Ex. INPUT :
Size of Array : 1
Enter the elements : 1
OUTPUT :
No second maximum
4. Print the following pattern
Ex. INPUT : 5
OUTPUT :
1
11
121
1331
14641

Ex. INPUT : 7
OUTPUT :
1
11
121
1331
14641
1 5 10 10 5 1
1 6 15 20 15 6 1
5. Given a two dimensional array which consists of only 0’s and 1’s. Print the matrix without
duplication.
Ex. INPUT :
Enter Row Size : 4
Enter column size : 3
Enter the matrix :
101
110
111
101
OUTPUT :
Unique Matrix :
101
110
111
6. Given an array of positive numbers. Print the numbers which have longest continuous range.
Ex. INPUT :
Enter array size :
Enter arryay elements : 1 3 10 7 9 2 4 6
OUTPUT :
1234
Ex. INPUT :
Enter array size : 8
Enter arryay elements : 1 3 9 7 8 2 4 6
OUTPUT :
1234
6789
7. Given two arrays. Find its union.
Input :
Enter size of first array : 6
Enter the elements : 123453
Enter size of second array : 4
Enter the elements : 1275
OUTPUT :
123457
8. Given an array of numbers. Print the numbers without duplication.
INPUT :
Enter the array size : 4
Enter the elements : 1 1 2 4
OUTPUT :
124
9. Given an array of numbers and a number k. Print the maximum possible k digit number
which can be formed using given numbers.
INPUT :
Enter the array size : 4
Enter the elements : 1 4 973 97
Enter number of digits : 3
OUTPUT :
974
INPUT :
Enter the array size : 6
Enter the elements : 1 4 89 73 9 7
Enter number of digits : 5
OUTPUT :
98973
10. Given an array of numbers and a window of size k. Print the maximum of numbers inside
the window for each step as the window moves from the beginning of the array.
INPUT :
Enter the array size : 8
Enter the elements : 1,3,5,2,1,8,6,9
Enter the window size : 3
OUTPUT :
555889
SET-5
1.Given 4 integers as input. Find whether they would form a rectangle, square or none.
Insert an element at a particular index in an array.
2.Given a large number convert it to the base 7.
3.Given an IP address validate it based on the given conditions.
4.Sort parts of an array separately using peak values.
5.Given an input array, find the number of occurrences of a particular number without
looping (use hashing)
6.Diamond pattern printing based on some conditions
7. Given an array of characters print the characters that have ‘n’ number of occurrences. If a
character appears consecutively it is counted as 1 occurrence
Eg: a b a a b c c d e d
Here a has only 2 occurrences
SET-6
1) Evaluate given expression which has factorials and exponential terms.
2)To implement snake and ladder game for given two-dimensional array having position of
snakes and ladders
3)To calculate strength of the password string using some predefined rules given in the
question
4)Given four points, We have to say whether it is square or rectangle or any other shape
SET-7
1. Print second frequently occurring number in given series
Example :
Input: 1 1 2 3 1 2 4
Output: 2
Explanation: 1 occurs 3 times, 2 occurs 2 times, 3 occurs 1 time and 4 occurs 1 time. Hence
second frequently occurring number in given series is 2
2. Print only numbers which is present in Fibonacci series (0 1 1 2 3 5 8 ……..)
Input: 2 10 4 8
Output: 2 8
Input: 1 10 6 8 13 21
Output: 1 8 13 21
3. Print pattern like this
Example:
Input: 1
Output: 0
Input: 2
Output:
00
01
10
11
Input: 3
Output:
000
001
010
011
100
101
110
111
4. NxN matrix will be provided. 0->block, 1->Not a block
Always starting point is (0,0), Ending point is (N-1,N-1).
You have to go from starting point to ending point. One valid solution is enough.
Example:
Input:
N=4
1100
1001
1111
0001
Output:
_100
_001
____
000_
5. Insert 0 after consecutive (K times) of 1 is found.
Example:
Input:
Number of bits: 12
Bits: 1 0 1 1 0 1 1 0 1 1 1 1
Consecutive K: 2
Output:
1011001100110110
Input : [ 10, 20, 30, 12, 5 ]
[ 10, 5, 30, 20 ]
Output : 12 is the extra element in array 1 at index 4
Input : [ -1, 0, 3, 2 ]
[ 3, 4, 0, -1, 2 ]
Output : 4 is the extra element in array 3 at index 5
SET-8

1. Find the least prime number that can be added with first array element that makes them
divisible by second array elements at respective index (check for prime numbers under
1000, if exist return -1 as answer) & (Consider 1 as prime number)
Input : [ 20, 7 ]
[ 11, 5 ]
Output : [ 1, 3 ]
Explanation :
(20 + ?) % 11
( 7 + ?) % 5
2. Sort the array elements in descending order according to their frequency of occurrence
Input : [ 2 2 3 4 5 12 2 3 3 3 12 ]
Output : 3 3 3 3 2 2 2 12 12 4 5
Explanation : 3 occurred 4 times, 2 occurred 3 times, 12 occurred 2 times, 4 occurred 1
time, 5 occurred 1 time
Input : [ 0 -1 2 1 0 ]
Output : 0 0 -1 1 2
3. Print true if second string is a substring of first string, else print false.
Note : * symbol can replace n number of characters
Input : Spoon Sp*n Output : TRUE
Zoho *o*o Output : TRUE
Man n* Output : FALSE
Subline line Output : TRUE

SET-9

1. prime number – print n prime numbers


2. prime factor – sort the array based on the minimum factor they have.
3. adding a digit to all the digits of a number eg digit=4, number = 2875, o/p= 612119
4. form the largest possible number using the array of numbers.
5. lexicographic sorting.
6. given a set of numbers, and a digit in each iteration, if the digit exists in any of the
numbers, remove its occurrences and ask for the next digit till the list becomes empty.
7. Check if a number ‘a’ is present in another number ‘b.
Finding middle element, Sorted insert, reversing LL, merging 2 LLs in sorted, removing
duplicate elements and so on.
SET-10

1. Print longest sequence between same character


Ex I/p abcccccbba
O/p 8 (from a to a)
I/p aaaaaaaa
O/p 6
2.sort the array odd numbers in ascending and even numbers in descending.
I/p 5 8 11 6 2 1 7
O/p 1 5 7 11 8 6 2
3. It’s about anagram.i/p was array of strings .and a word was given to find whether it has
anagram in given array.
I/p catch, got, tiger, mat, eat, Pat, tap, tea
Word: ate
O/p eat, tea
4.array of numbers were given to find a number which has same sum of numbers in it’s
either side.
I/p 1, 2, 3, 7, 6
O/p 7(has 1+ 2+3 in left 6 in right)

SET-11

1.Given two dimensional matrix of integer and print the rectangle can be formed using
given indices and also find the sum of the elements in the rectangle
Input: mat[M][N] = {{1, 2, 3, 4, 6}, {5, 3, 8, 1, 2}, {4, 6, 7, 5, 5}, {2, 4, 8, 9, 4} };
index = (2, 0) and (3, 4)
Output:
Rectangle
46755
24894
sum 54
2. Find the result subtraction, multiplication, division of two integers using + operator.
Input: 6 and 4
output:
addition 6+4 = 10, subtraction 6+(-4) = 2, multiplication = 24, division = 1
Input : -8 and -4
Output:
addition -8+(-4) = -12, subtraction (-8)+(-(-4)) = -4, multiplication = 32, division = 2
3.Given a sentence of string, in that remove the palindrome words and print the remaining.
Input:
He did a good deed
Output:
He good
Output:
Hari speaks
4.Given two dates, find total number of days between them.
Input: dt1 = {10, 2, 2014} dt2 = {10, 3, 2015}
Output: 393
dt1 represents “10-Feb-2014” and dt2 represents “10-Mar-2015” The difference is 365 + 28
Input: dt1 = {10, 2, 2000} dt2 = {10, 3, 2000}
Output: 29
Note that 2000 is a leap year
Input: dt1 = {10, 2, 2000} dt2 = {10, 2, 2000}
Output: 0
Both dates are same
Input: dt1 = {1, 2, 2000}; dt2 = {1, 2, 2004};
Output: 1461
Number of days is 365*4 + 1
5.Let 1 represent ‘A’, 2 represents ‘B’, etc. Given a digit sequence, count the number of
possible decodings of the given digit sequence.
Examples:
Input: digits[] = “121”
Output: 3 // The possible decodings are “ABA”, “AU”, “LA”
Input: digits[] = “1234” Output: 3
// The possible decodings are “ABCD”, “LCD”, “AWD”
6. Print all possible words from phone digits

SET-12
1. Given two Strings s1 and s2, remove all the characters from s1 which is present in s2.
Input: s1=”expErIence”, s2=”En”
output: s1=”exprIece”
2. Find the next greater element for each element in given array.
input: array[]={6, 3, 9, 10, 8, 2, 1, 15, 7};
output: {7, 5, 10, 15, 9, 3, 2, _, 8}
If we are solving this question using sorting, we need to use any O(nlogn) sorting
algorithm.
3. Print all distinct permutations of a given string with duplicate characters.
https://www.geeksforgeeks.org/distinct-permutations-string-set-2
4. Given a number, find the next smallest palindrome.
5.Given an array with repeated numbers, Find the top three repeated numbers.
input: array[]={3, 4, 2, 3, 16, 3, 15, 16, 15, 15, 16, 2, 3}
output: 3, 16, 15

SET-13
1.Print the given input string in ‘X’ format.
Note: The string length will be of odd length.
2. Two sorted arrays will be given. Create an array consisting of the elements of two arrays
with duplicate elements removed in sorted order.
Note: Use only one loop. No sorting.
3. Two strings of equal length will be given. Print all the adjacent pairs which are not equal.
Input: asdfghij and adsfgijh
Output: sd-ds, hij-ijh
4. Find the frequency of all numbers in an array.
Note: use dynamic memory allocation.
For example, if the input is {1, 2, 45, 67, 1, 88}, do not calculate the frequency of all
elements from 1 to 88.
5. From the input sentence given, find the strings which are not palindrome and print it.
Input: he knows malayalam
Output: he knows

You might also like