Zoho Round 2
Zoho Round 2
Question 1:
Finding the minimum duration between the given array of time
Question 2:
Determine if there is a subset of a given array with sum equal to given sum.
Question 3:
Print n*m array in given format.
Question 4:
Generate look and say series for nth term
Question 5:
String reverse
Question 6:
Zigzag traversal in 2 d matrix
Question 7:
Dialing pad codes
Question 8:
Spiral traversal in 2 d matrix
Question 9:
Pendulum sort
Question 10:
Input:
String1: i am Praveen
Question 11:
Input:. 12500
Question 12:
Input:.
Output: Yes
Question 13:
Input:. [12:34:55,1:12:13,8:12:15]
Output:. 4:22:40
Explanation:.
Smallest is 4:22:40
Question 14:
Input:. babca
Output: 9
Question 15:
Example:
Input: 64
Output: 55+8+1
Question 16:
Given a String with numbers and operators. Perform the operation on the
numbers in their respective order. Operator precedence need not be
considered.
The input string will have the numbers followed by the operators.
Example:
Result: 6 [Explanation: 1 * 2 + 3 - 4 + 5 = 6]
Question 17:
Example:
Input (5,7,3,1,4,6,2)
Question 18:
Assume a two dimensional string array. Each array contains child and father
details. O'th element is the child and '1'st is the parent. Write a program to
accept a name and find the number of children and grand children he has.
Don't use any brute force methods.Assume names are unique.
Example:
Data:
[Surya, Sivakumar],
[Karthi, Sivakumar],
[Sivakumar, Rakkaiya).
[Dev, Surya),
[Umayaal, Karthi],
[Diya, Surya],
[Prabu, Sivaji],
[Vikram, Prabu]
Examples:
Input: Surya, 1
Output: 2
Input: Karthi, 1
Output: 1
Input: Sivakumar, 2
Output 3
Question 19:
Given a positive integer N, the task is to find the nearest Fibonacci number
to the given integer N. If there are two Fibonacci Numbers having same
difference from N, then print the smaller value.
Question 20:
Question 21:
Question 22:
Length of Longest Substring without repeating characters GFG
Question 23:
word1: there
word2: been
o/p: 3 (in between , 'there' and 'been' there are minimum 3 words)
Question 24:
Question 25:
Question 26:
Question 27:
https://leetcode.com/problems/maximum-product-subarray/
Question 28:
Question 29:
within the array that has largest product, and return the product
Question 30:
Given a list of distinct integer pushes and another list of integer
pops, return whether this a valid sequence of stack push and pop
actions
Question 31:
Question 32:
Question 33:
Each element in an array will have the rank. You have to sort the elements
of the array based on rank. If two elements have the same rank then the
element must be sorted based on their numeric values.
Array: [1,5,6,3,10]
Rank: [100,0,1,100,2]
Op: [5,6,10,1,3]
Question 34:
Question 35:
Pattern printing
121
12321
1234321
123454321
Question 36:
https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii
Question 37:Check if the given push and pop sequences of Stack is valid or
not.
https://www.geeksforgeeks.org/check-if-the-given-push-and-pop-
sequences-of-stack-is-valid-or-not/
Question 38:
Question 39:
Output:13
Question 40:To find the length of the maximum size turbulent sub array. A
sub array is turbulent if the comparison signs changes for every adjacent
pairs of the elements in a subarray.
Sample input: 9 4 2 8 6 7 7 2 10
Output:5
Question 41:
To find the maximum profit from the array of prices given for the nth day.
You may complete atmost 2 transactions .
Sample Input:3 3 5 0 0 3 1 4
Output:6
Question 42:Given an N jobs with start time and end time and CPU
load .Print the maximum CPU load for a particular time.
Input:4(no of jobs)
035
248
598
156
Output: 19
Question 43:
Eg : Input : 4 8 2 5 5 6
Output : 25
Question 44:
Eg : 1. Input : 1 2 3 4 5
Output : 3
2. Input : 18 15 25 14 10
Output : 15
Question 45:
can take only 2 meals per day. The second meal should
constraints.
Eg : Input : 0 4 21 26 44
Output : yes
Input : 0 17 21 39 44 62
Output : yes
Input : 0 4 20 26 44
Output : no
Question 46:
trap or not.
Trap conditions:
is a trap).
• In the given two numbers, if any one of the number
remains unchanged)
Eg : Input : 2 10 12
Output : yes
Question 47:
Given an array, move all the zeroes to the end of the array
Question 49:
Write a program to find the position of the seat in the flight if the seat
number is given.
print “CS”.
INPUT 1
22
OUTPUT
CS
INPUT 2
41
OUTPUT
MS
INPUT 1
WS MS CS CS MS WS
123
12 11 10
13 14 15
24 23 22
25 26 27
36 35 34
37 38 39
48 47 46
456
987
16 17 18
21 20 19
28 29 30
33 32 31
40 41 42
45 44 43
OUTPUT:
WS
Question 50:Given an array, tell if there exists an element in the array such
that the sum of the elements to its left side is equal to the sum of the
elements to its right side
Input: 4 2 4 3 5
Output: 15
Question 52: Given an array of numbers find the average of the numbers in
the list and return the average
Input: 1 2 3 4 5
Output: 3
Input: -12 4 2 7 8 9
Output: 2(or 4)
Question 53:
Given an array of number, find whether the number follows the given
sequence or not.
(or)
Input: 0 3 21 26 39
Output : No
Input: 0 4 21 26 39
Output : No
1. if x==y
2. if x is a multiple of y.
If the number is not trap , then find the sum of digits and try it with above
condition.
If the number in the range is trap increment y by 2 , if not trap after sum of
digit also then decrement
the y by 1.
Output is to print the trap numbers from the range N1 and N2.
Q5. Given an n*n matrix , traverse the matrix in a particular order from 0,0
to n,n and return to 0,0. The
-1 – block.
Question 56:
Question 57:
Question 58:
Printing the sum of arrays excluding the odd numbers following the even
number.
Question 59:
Sum of the elements in the array.If any odd number occurs after an even
number skip that element alone.
Testcase1:
Input:1 2 3 4 6
Testcase2:
Input:5 3 2 4 6 7 1
Question 60:
Given two arrays print the first element of first array as first and then the
first element of second array and so on.
Input - 20 30 40 50
1 2 3 4
Output – 20 1 30 2 40 3 50 4
Question 61:
Fasting rule
i. A person should eat two meals between 8 hours and there should be
more than 3 hours difference between two meal times.
ii. After that two meals ,the person should not eat anything for the next
16 hours.
A) Input : 2 7 27 32 48
Output : YES
B) Input : 2 3 19 24 41 45
Output : NO
Question 62:
Given two arrays A and B containing N integers, find a number from A and
another number from B such that their sum is minimum and their index
positions are not same.
INPUT:
54321
52145
Output:
Question 63:
Reversing K continuous numbers from a list, if the number of
Ex:
Array = [1,2,3,4,5,6,7,8]
K=3
Output [3,21,6,5,4,8,7]
Array = [1,2,3,4,5,1]
K=5
Output [5,4,3,2,1,1]
Question 64:
Output:
[1,2,3,4,5]
Output:
[1,2,9]
Question 65:
Find the longest subarray with equal number of one’s and zero’s
from an array.
Ex: [1,0,1,1,1,0,0,1]
Output:
1 to 6
Ex: [0,1,0,1,0,1,0,1]
Output:
0 to 4
Input : occurrence
Output : o1c3u1r2e1n1
https://leetcode.com/problems/group-anagrams/description/
https://leetcode.com/problems/climbing-stairs/description
Input : 4
Output :
4444444
4333334
4322234
4321234
4322234
4333334
4444444
Example1 :
Output: {7, 5, 1, 6, 3, 2, 9, 8, 7}
Example2 :
Output: {5, 4, 3, 2, 1, 8, 7, 6}
Question 71:
vowels
Example:
input: "alphabet"
output: "pha"
input: "hhhhhhappa"
output: "pp"
input: "hhhhhhapp"
output: ""
Question 72:Find the from and to index of the longest subarray with equal
number
of 0 and 1.
Input:
a =[1,1,0,0,1,0,0]
Output:
0 to 5
Input:
a =[1,1,1]
Output :
No index found