ZOHO INTERVIEW QUESTION
(22ND AND 23rd MARCH 2025)
PROBLEM 1
Write a program to print the following pattern for a given integer n:
Example input : 5
Example output:
1
26
3 7 10
4 8 11 13
5 9 12 14 15
The numbers should follow the sequence where each row starts with the row number and
increments by (n-j) for each subsequent number in the row (where j is the column position).
PROBLEM 2
Leaders in an array
Given an array of integers print all the leaders in the array. A leader is an element that is
greater than all the elements to its right. The output should be in the same order as they occur
in the input array.
Example input: [16,17,5,5,2]
Example output: 17 5 2
MEDIUM TO HIGHER LEVEL QUESTIONS
PROBLEM 3
Unmatched substrings
Given two strings of equal length, find and print all the substrings where the characters at the
same positions in both strings are different. The output should display the mismatched
substrings from both strings
Example input: schoollifeisusefull, schoollongofuselike
Example output: life , long
Usefull , uselike
PROBLEM 4
Maximum Consecutive Subarray
Given a binary array (containing only 0’s and 1s), find the length of the longest consecutive
subarray of the same digit. If no such subarray exists, print “no subarray found”
Example input: [1,1,0,0,1,0,1,0,1,1,1,1]
Example output: 4
PROBLEM 5
Data manipulation (Add days to date)
Given a date in DD-MM-YYY format and an integer N , write a program to add N days to the
given date and print the new date in the same format. The solution must account for leap
years and varying month lengths
Example input: 31-12-2025 , N=3000
Example output: 26-11-2034
March 23, 2025 (Day 2)
Problem 6
Snake pattern matrix traversal
Given a 2D square matrix, print its elements in snake pattern: first row left to right, second
row right to left, and so on….
Example input:
[[1,2,3],
[4,5,6],
[7,8,9]]
Example output:
123
654
789
PROBLEM 7
Binary addition:
Given two binary strings, write a program to compute their sum and return the result as a
binary string
Example input: 10011, 11000
Example output: 101011
PROBLEM 8
Largest Number Formation
Given an array of non negative integers, arrange them to form the largest possible number
and print it
Example input: [8,7,1,9]
Example output: 9871
(2 April 2025)- ROUND 2
PROBLEM 1
Find second largest element
Conditions
1. If the array contains only one or no element, return -1.
{10} or {}
2. If all elements are the same, return that element
{5,5,5} return 5
3. If the array has duplicates but a valid distinct second largest exists, return the second
largest
{5,5,4} return 4
Sample input1:
{-1,-2,-3,10,10}
Sample output1:
-1
Sample input2
{-1,-1,-1}
Sample output2
-1
Modify the code so that it should be find the third largest number
your code should be efficient in such a way that we can able to find n largest number
PROBLEM 2
Check if a given string is a palindrome
Conditions
1. Ignore case sensitivity
str = ‘Aa’ it is a palindrome
2. Ignore all non alphabetic character
str = “ @abcaba#” it is a palindrome
3. Ignore spaces – skip characters
str =” ababa” it is a palindrome
PROBLEM 3
Find the missing numbers from 0 to n distinct numbers
Conditions:
1. Array should be start from 0 upto n
2. No duplicates allowed
3. Atleast one missing number would be there
Sample input1:
[3,0,1]
Sample output:
2
Sample input2:
[1,2,3,0]
Sample output2:
4
Sample input3:
[1,2]
Sample output3:
0
Constraints : time complexity 0(n)
PROBLEM 4
Find non repeating character in a string
Conditions:
1. If no such character exists, return -1
2. The comparison is case sensitive
3. Special characters and symbols are also counted
Time complexity:
0(n)
Space complexity:
0(1)
PROBLEM 5 (MEDIUM TO HARD LEVEL )
Find the longest substring without repeating characters
Conditions:
1. Return the length of the longest substring without repeating characters
2. The comparison is case sensitive
3. All characters, including special characters, are considered
input:
abaabcdae
output:
4
Explanation
abcd
sample input2:
abaabcdAa
output:
5
explanation:
abcdA
Sample input 3
aba@abcd@Aa
Output:
7
Explanation
abcd@Aa