Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 38

Set 1)

4. Given a 9×9 sudoku we have to evaluate it for its correctness. We have to check
both the sub matrix correctness and the whole sudoku correctness.
-----------------------------------------
Set 2)
3. Form a number system with only 3 and 4. Find the nth number of the number
system.
Eg.) The numbers are: 3, 4, 33, 34, 43, 44, 333, 334, 343, 344, 433, 434, 443, 444,
3333, 3334, 3343, 3344, 3433, 3434, 3443, 3444 ….
---------------------------------------
Set 3)
4. Find if a String2 is substring of String1. If it is, return the index of the
first occurrence. else return -1.

Eg 1:Input:
String 1: test123string
String 2: 123
Output: 4
Eg 2: Input:
String 1: testing12
String 2: 1234
Output: -1
5. Given two sorted arrays, merge them such that the elements are not repeated

Eg 1: Input:
Array 1: 2,4,5,6,7,9,10,13
Array 2: 2,3,4,5,6,7,8,9,11,15
Output:
Merged array: 2,3,4,5,6,7,8,9,10,11,13,15

---------------------------------------
Set 4)
1) To find the odd numbers in between the range.
Input:
2
15
Output:
3,5,7,9,11,13

2) To find the factors of the numbers given in an array and to sort the numbers in
descending order according to the factors present in it.
Input:
Given array : 8, 2, 3, 12, 16
Output:
12, 16, 8, 2, 3

3) To output the number in words (0-999)


Input: 234
Output: Two hundred and Thirty Four

4) To find the print the pattern:Ip: n=5


Op:
1
1 1
2 1
1 2 1 1
1 1 1 2 2 1
5) A man his driving car from home to office with X petrol. There are N number of
petrol bunks in the city with only few capacities and each petrol is located in
different places For one km one liter will consume. So he fill up petrol in his
petrol tank in each petrol bunks. Output the remaining petrol if he has or tell him
that he cannot travel if he is out of petrol.
Input:
Petrol in car: 2 Liters
Petrol bunks: A B C
Distance from petrol each petrol bunks: 1, 5, 3
Capacities of each petrol bunk: 6, 4, 2
Output:
Remaining petrol in car is 5 liters

Level two:
1) Print the given pattern:
Input:
N= 3, M=3
Output:
X X X
X 0 X
X X X

Input:
N=4 M=5
Output:
X X X X
X 0 0 X
X 0 0 X
X 0 0 X
X X X X

Input:
N=6 M=7
X X X X X X
X 0 0 0 0 X
X 0 X X 0 X
X 0 X X 0 X
X 0 X X 0 X
X 0 0 0 0 X
X X X X X X

2) To find the number of groups and output the groups:


Explanation: 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.
Input:
Array: 3, 9, 7, 4, 6, 8
X: 3
Output:
3, 9
3, 6
9, 6
3, 9, 6
No of groups: 4

Level three:
1) To output the given string for the given input which is an integer.Input:
1Output: AInput: 26Output: ZInput : 27Output: AAInput: 28:Output: ABInput:
1000Output: ALL

2) Input:
Number of elements in set1: 4
Elements are: 9, 9, 9, 9
Number of elements in set 2: 3
Elements are: 1,1,1
Output:
1, 0, 1, 1, 0
Input:
Number of elements in set1: 11
Elements are: 7,2,3,4,5,3,1,2,7,2,8
Number of elements in set 2: 3
Elements are: 1,2,3
Output: 7,2,3,4,5,3,1,2,8,5,1
---------------------------
5)
Program 1:
Help john to find new friends in social network
Input:
3
Mani 3 ram raj guna
Ram 2 kumar Kishore
Mughil 3 praveen Naveen Ramesh

Output:
Raj guna kumar Kishore praveen Naveen Ramesh

Program 2:
Input:
With the starting and ending time of work given find the minimum no of workers
needed

Start time end time


1230 0130
1200 0100
1600 1700
Output:
2

Program 3:
Find the union intersection of two list and also find except (remove even elements
from list1 and odd elements from list2)
Input

List 1: 1,3,4,5,6,8,9
List 2: 1, 5,8,9,2

Union: 1, 3,4,5,6,8,9,2
Intersection: 1,5,8,9
Except: 1, 3, 5,9,8,2
Program 4:

Rotate the matrix elements


For 3*3 matrix
Input
1 2 3
4 5 6
7 8 9

Output:
4 1 2
7 5 3
8 9 6

For 4*4 matrix


Input:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16

Output:
5 1 2 3
9 10 6 4
13 11 7 8
14 15 16 12
Program 5:
Find the largest possible prime number with given no
Input
5
4691
Output:
9461

Program 6:
Basic programs like pattern printing
1
22
333
4444
And
1
2 4
3 5 7
6 8 10 12
-----------------------------------------
6)
Q1. Given dates in day,month, year order sort them.

Q2. Given a string of integers find out all the possible words that can made out of
it in continuous order. Eg: 11112

ans: AAAAB
AKAB
AAKB
AAAL etc.

Q3: Find whether a given number is magic number or not. It is something which gives
same digits even after cubing it.
Q4: something related to rotating an array.

Q5: Given two numbers and an operation either + or – , perform the operation.
Now remove any zeros if present in the two numbers and perform an operation. See if
the result obtained is same or not after removing zero’s in the original result.
--------------------------------------
7)
1. Cyclic number verification
2. Sorting dates
3. write a code to solve given mathematical expression
4. generation of unique number from any random number
5. given a number u need to print all combination of aphabets for that number
----------------------------
8)
1. Spiral printing.
O/P
4444444
4333334
4322234
4321234
4322234
4333334
4444444

2. Sort the array alternately i.e first element should be max value, second min
value, third second max, third second min. Eg: arr[] = {1,2,3,4,5,6,7} O/P:
{7,1,6,2,5,3,4} Note: no extra space and time complexity should be less;

3. Print all the substring of the given string.

4. Print the numbers which are mismatched from two array. Arr1 = {a b c d e f g h
i}
arr2 ={ a b d e e g g i i}, O/P- cd, de, f, g, h, i.

5. Print all possible combinations from the given string.

The candidate who solved at least four out five are selected for next advance
coding round.
---------------------------------
9)
10)
Question 1: Given two sorted arrays output a merged array without duplicates.
Array1: [1, 2, 3, 6, 9]
Array2: [2, 4, 5, 10]
Merged Array: [1, 2, 3, 4, 5, 6, 9, 10]

Question 2: Given a sliding window of size k print the maximum of the numbers under
the sliding window.
Example: Consider a sliding window of size k equals 3. Let the array be
[3,2,7,6,5,1,2,3,4] the output should print 7 as the first output as first window
contains {3,2,7} and second window contains {2,7,6} and so on and the final output
is {7,7,7,6,5,3,4}
Question 3: Given a array with n elements print the number of occurrences of that
number each number in that array. The order of number doesn’t matter. You can
reorder the elements.
Example : [2,1,3,2,2,5,8,9,8]
Output:
2-3
1-1
3-1
5-1
8-2
9-1

Question 4: Enter two strings from command line and check whether any substring
present in first string that follows the pattern of second sting.. They asked to
implement regular expressions for * and backslash without built in functions.

“abcd” “a*cd” answer : yes


“aaaa” “a*” answer : yes
“a*c” “a\*c” answer:yes
“adsd” “ad” answer:no

Question 5: They gave a passage and the output should be printing out the number of
occurrence of each word and the indices it occurs without using string matching

The passage given was “jana Gana Mana” and so on.. and we have to print number of
jana and it’s indices.i.e at which position it occurs.

I have completed first and 5th program. The programs were not of equal weight-age.
4th and 5th were given more weight-age. They gave importance with the way of
approach. Another guy solved the first 4 programs but he is not selected because of
his inefficient code. And I got selected to the next round just because of the
appropriate data structure and logic the applied.
-----------------------------------
11)
12)
1.Given two numbers a and b both < 200 we have to find the square numbers which lie
between a and b(inclusive)

eg) i/p a = 20;b = 100;


o/p 25,36,49,64,81,100
2.Alternately sort an unsorted array..

eg) i/p {5,2,8,7,4,3,9}


o/p {9,2,8,3,7,4,5}
3. Given an array and a threshold value find the o/p

eg) i/p {5,8,10,13,6,2};threshold = 3;


o/p count = 17
explanation:
Number parts counts
5 {3,2} 2
8 {3,3,2} 3
10 {3,3,3,1} 4
13 {3,3,3,3,1} 5
6 {3,3} 2
2 {2} 1
4.a. Given two binary numbers add the two numbers in binary form without converting
them to decimal value.
eg) a = 1010 b = 11001
o/p 100011
b.The two numbers were given in base n
eg) a = 123 b = 13 n = 4
o/p 202
5.Write a program to print the below pattern

for n = 6
1 7 12 16 19 21
2 8 13 17 20
3 9 14 18
4 10 15
5 11
6
6.Given bigger NxN matrix and a smaller MxM matrix print TRUE if the smaller matrix
can be found in the bigger matrix else print FALSE

7.Given two matrices a and b both of size NxN find if matrix a can be transformed
to matrix b by rotating it 90deg , 180deg , 270deg if so print TRUE else print
FALSE

8 In addition to the above question you have to check if matrix a can be


transformed by mirroring vertically or horizontally to matrix b.
--------------------------------
13)
You’re given an array. Print the elements of the array which are greater than its
previous elements in the array.
Input : 2, -3, -4, 5, 9, 7, 8 Output: 2 5 9You should solve this question in
O(n) time.
You’re given an even number n. If n=4, you have to print the following pattern :
44444334
4334

4444

If n=6, then the pattern should be like this :

666666

655556

654456

654456

655556

666666

You’re given a number n. If write all the numbers from 1 to n in a paper, we have
to find the number of characters written on the paper.For example if n=13, the
output should be 18 if n = 101, the output should be 195
A number is called as binary-decimal if all the digits in the number should be
either ‘1’ or ‘0’. Any number can be written as a sum of binary-decimals. Our task
is to find the minimum number of binary-decimals to represent a number.Input :
32Output : 10 11 11
Input : 120

Output : 10 110

You’re given a string as an input. You have to reverse the string by keeping the
punctuation and spaces. You have to modify the source string itself with creating
an another string.
Input :A man, in the boat says : I see 1-2-3 in the sky
Output :

y kse, ht ni3 21ee slsy : a sta o-b-e ht nin amA


---------------------------------------
14)
1) Given a number, convert it into corresponding alphabet.

Input Output
1 A
26 Z
27 AA
676 ZZZ
2) Given a Roman numeral, find its corresponding decimal value.

3) Write a program to print all permutations of a given string. Note here you need
to take all combinations as well, say for the input ABC the output should be as
follows:

Input: ABC
Output:
A
B C
AB AC BA BC CA CB
ABC ACB BCA BAC CBA CAB
4) Write a program to rotate an n*n matrix 90,180,270,360 degree.
is the solution for rotating a matrix 90 degree. For rotating the matrix
180,270,360 degree, u need to call the same method 2,3,4 times based on the input.

5) Reverse words in a given string

6) Write a program to convert a number into a mono-digit number.

Conditions:
a) You are allowed to add and subtract the consecutive digits (starting from left).
b) You are allowed to do only one operation on a digit.
c) You cannot perform any operation on a resultant digit of the previous operation.
d) Your code should also find if a given number cannot be converted to a mono digit
number.

Input Output
72581 7(2+5)81
77(8-1)
777
3962 cannot create a mono digit number
-----------------------------------
15)
1) Given an array, find the minimum of all the greater numbers for each element in
the array.

Sample:
Array : {2, 3, 7, 1, 8, 5, 11}

Output:
{2>3, 3>5, 7>8, 1>2, 8>11, 5>7, 11>}
2) Find the largest sum contiguous subarray which should not have negative numbers.
We have to print the sum and the corresponding array elements which brought up the
sum.

Sample:
Array : {2, 7, 5, 1, 3, 2, 9, 7}

Output:
Sum : 14
Elements : 3, 2, 9
3) Given a string, we have to reverse the string without changing the position of
punctuations and spaces.

Sample: house no : 123@ cbe


Output: ebc32 1o : nes@ uoh
4) Given a 2D grid of characters, you have to search for all the words in a
dictionary by
moving only along two directions, either right or down. Print the word if it
occurs.

Sample :
a z o l
n x h o
v y i v
o r s e
Dictionary = {van, zoho, love, are, is}

Output:
zoho
love
Is

5) Given a string, change the order of words in the string (last string should come
first).
Should use RECURSION

Sample: one two three


Output : three two one
------------------------------------
16)
They gave questions one after the other. Initially it was easy, then ,the
difficulty level increased. The first one was to check whether a year is leap year
and the last one was to sort numbers based on digits starting from most significant
numbers. Eg: input-100 1 11 21 2 3. Output-1 100 11 2 21 3
Each question was a continuation of the previous one, so its good if code is
written as function.

In this round, they asked about kernel, some puzzles , print letter ‘X’ using ‘*’.
An array contains values between 0 to n-1. Task is to find the duplicate numbers
with time complexity o(n) and space complexity o(1). (Use hashing on the same
array- add n to a value if the index has already been visited)
-----------------------------------------
17)
1. Given an odd length word which should be printed from the middle of the word.
The output should be in the following pattern.
Example:

Input: PROGRAM
Output:
G
GR
GRA
GRAM
GRAMP
GRAMPR
GRAMPRO
2. It is a program to implement Least Recently Used (LRU) concept. Given a key, if
it is already existed then it should be marked as recently used otherwise a value
should be stored which is given as input and marked as recently used. The capacity
is to store only 10 key, value pairs. If the table is full and given a new key; the
key, value pair which is not recently used should be deleted which gives
feasibility to store the new key, value pair.

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}
];

Syam 2

Output: 3 (Syam has Ram and Akil in level 1 and in level 2 he have Nikil, Subhash,
Karthik. So the answer is 3).

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
---------------------------------------------
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
9 2 8 1 3 5 6 7 3 1 1 6
Number of digits:9
7 8 4 6 2 1 9 9 7
Output :
9 2 8 9 2 0 2 9 5 1 1 3

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}

Advanced programming.

You are given coordinates as input


(0 0 ) (0 1 ) ( 0 2) (0 3) (1 5) (1 4 ) (3 5 )

1. Check if the given points lie in the same line

2. GIven a point find the points on the largest line [in terms of the points it
contain ] passing through that point
Input : 0 1
Output : (0 0 ) (0 1) (0 2 ) (0 3 )

3. Given 2 points find the points in between them.


Input (0 0) (0 3 )
Output : (0 1) (0 2 )

4. Find the number of points in the line with the largest number of points in it.

5. Given a point print all the lines passing through it [ie for each line print the
points in it ]

PREPARATION :This round usually consist on making modules and oop stuffs. This was
out of the blue. Previous problems, I just did Railway Reservation partially for
this round.
If you have done some projects and is good with oop you will get through no need to
practice specifically for this else brush up your OOP Designing skills and do some
previous questions.

I solved all the problems. The invigilator will be around


checking your code all the time, SO NO SLOPPY CODING GUYS!! They need good code.
Take a paper and figure out your aproch before solving each of them. And also check
if you could use one problem to solve the other. Here The function written for Q2
can be used for Q5 with some modification if you’re out of time.
-----------------------------------
19)
20)
21)
Question 1 : 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.

Question 2 : 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

Question 3 : Given a string, reverse only vowels in it; leaving rest of the string
as it is.

Input : abcdef
Output : ebcdaf

Question 4 : 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)

zoho_interview

Question 5 : 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.
If you like GeeksforGeeks and would like to contribute, you can also write an
article and mail your article to contribute@geeksforgeeks.org. See your article
appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more
information about the topic discussed above
---------------------------------
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
1 1 1 0
0 0 1 1
0 0 1 1

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.
--------------------------------------
23)
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 10

OUTPUT :

Ex. INPUT :

Size of Array : 4
Enter the elements : 4 1 2 2

OUTPUT :

Ex. INPUT :

Size of Array : 1
Enter the elements : 1

OUTPUT :

No second maximum
4. Print the following pattern

Ex. INPUT : 5

OUTPUT :

1
1 1
1 2 1
1 3 3 1
1 4 6 4 1

Ex. INPUT : 7

OUTPUT :

1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
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 :
1 0 1
1 1 0
1 1 1
1 0 1

OUTPUT :

Unique Matrix :
1 0 1
1 1 0
1 1 1
6. Given an array of positive numbers. Print the numbers which have longest
continuous range.

Ex. INPUT :

Enter array size : 8


Enter arryay elements : 1 3 10 7 9 2 4 6

OUTPUT :

1 2 3 4

Ex. INPUT :

Enter array size : 8


Enter arryay elements : 1 3 9 7 8 2 4 6

OUTPUT :

1 2 3 4
6 7 8 9
7. Given two arrays. Find its union.

Input :

Enter size of first array : 6


Enter the elements : 1 2 3 4 5 3
Enter size of second array : 4
Enter the elements : 1 2 7 5

OUTPUT :

1 2 3 4 5 7
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 :
1 2 4
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 :

5 5 5 8 8 9
--------------------------------------------
24)
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.

Some were average:

Given a large number convert it to the base 7.


Given an IP address validate it based on the given conditions.
Sort parts of an array separately using peak values.

Some were a bit challenging:

Given an input array, find the number of occurrences of a particular number without
looping (use hashing)
Diamond pattern printing based on some conditions
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
--------------------------------------------
25)
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
----------------------------------------------
26)
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 ……..)

Example:

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:
0 0
0 1
1 0
1 1

Input: 3
Output:
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
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
1 1 0 0
1 0 0 1
1 1 1 1
0 0 0 1
Output:
_ 1 0 0
_ 0 0 1
_ _ _ _
0 0 0 _
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:
1 0 1 1 0 0 1 1 0 0 1 1 0 1 1 0
----------------------------------------------
27)
1. Find the extra element and its index

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
2. 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
3. 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
Note : sort single occurrence elements in ascending order
4. 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
--------------------------------------------
28)
29)
prime number – print n prime numbers
prime factor – sort the array based on the minimum factor they have.
adding a digit to all the digits of a number eg digit=4, number = 2875, o/p= 612119
form the largest possible number using the array of numbers.
lexicographic sorting.
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.
Check if a number ‘a’ is present in another number ‘b.
I forgot the other 4.

Complexity is not an issue.

As soon as I finished 11 programs, they told me to come the next day for third
round.
-------------------------------------------------
30)
Finding middle element, Sorted insert, reversing LL, merging 2 LLs in sorted,
removing duplicate elements
Separate 0s and 1s in single array traversal
Finding the largest palindromic sub word in a given word
Finding height of a binary tree
-----------------------------------------
31
32)
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)


---------------------------------------------------
33)
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
4 6 7 5 5
2 4 8 9 4
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

Input:
Hari speaks malayalam
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


------------------------------------------------
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”
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.
Print all distinct permutations of a given string with duplicate characters.
https://www.geeksforgeeks.org/distinct-permutations-string-set-2
Given a number, find the next smallest palindrome.
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
---------------------------------------------
35)
1. Print the given input string in ‘X’ format.

Note: The string length will be of odd length.

https://www.geeksforgeeks.org/print-string-of-odd-length-in-x-format/

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
--------------------------------------------
36)
1. Given a text and a wildcard pattern, implement wildcard pattern matching
algorithm that finds if wildcard pattern is matched with text. The matching should
cover the entire text (not partial text).

The wildcard pattern can include the characters ‘?’ and ‘*’
‘?’ – matches any single character
‘*’ – Matches any sequence of characters (including the empty sequence)

Example:
Text = “baaabab”,
Pattern = “*****ba*****ab”,
output : true
Pattern = “baaa?ab”, output : true
Pattern = “ba*a?”, output : true
Pattern = “a*ab”, output : false
2. Given an input string and a dictionary of words, find out if the input string
can be segmented into a space-separated sequence of dictionary words. See following
examples for more details.

Consider the following dictionary


{ i, like, sam, sung, samsung, mobile, ice,
cream, icecream, man, go, mango}

Input: ilike
Output: Yes
The string can be segmented as "i like".

Input: ilikesamsung
Output: Yes
The string can be segmented as "i like samsung"
or "i like sam sung".<>
3.Print the following pattern

1
3 2
6 5 4
10 9 8 7
10 9 8 7
6 5 4
3 2
1
4.Given an array as input, The condition is if the number is repeated you must add
the number and put the next index value to 0. If the number is 0 print it at the
last.

Eg: arr[] = { 0, 2, 2, 2, 0, 6, 6, 0, 8}
Output: 4 2 12 8 0 0 0 0 0 .
----------------------------------------
37)
1.Given a String with or without special characters find if it is Palindrome or
Not.. No splitting of array must be done or No additional spaces must be used for
storing the array..

Eg: RACE CAR

Eg: I DID, DID I ?

2. Given an array of integers of size n. Convert the array in such a way that if
next valid number is same as current number, double its value and replace the next
number with 0. After the modification, rearrange the array such that all 0’s are
shifted to the end.

Input : arr[] = {2, 2, 0, 4, 0, 8}


Output : 4 4 8 0 0 0

Input : arr[] = {0, 2, 2, 2, 0, 6, 6, 0, 0, 8}


Output : 4 2 12 8 0 0 0 0 0 0

3 . TWISTED PRIME NUMBER

A number is said to be twisted prime if it is a prime number and reverse of the


number is also a prime number.

Input : 97
Output : Twisted Prime Number
Explanation: 97 is a prime number
and its reverse 79 is also a prime
number.
4.Given an array A[] and a number x, check for pair in A[] with sum as x.

Eg : Input {1, 2, 4, 3, 5, 6}
SUM : 5
Output : 2 (1, 4) & (2, 3)
5.Largest Sum Contiguous Subarray
(Kadane’ Algorithm )

6.Diamond pattern : for given input size -> Here 3

*
***
*****
***
*
--------------------------------------------------
38)
Problem 1:

Many students will able to solve 3 problems in this round. So make sure you stand
apart from the crowd.Their vacancy is going to be 5 for a team. The performance in
this round could be taken as a tie breaker for round 3.

input : aaabbcc

output : abc

Problem 2:

Evaluate the expression and sort and print the output. Getting the input is the
tricky part

Input:

Number of input : 4

2*3

2^2^2

35

3*1

Output:

3*1

2*3

2^2^2
35

Problem 3:

Given a 6 blocks, of different height h1, …, h6 . Make 2 towers using 3 Blocks for
each tower in desired height h1, h2. Print the blocks to be used in ascending order

Input:

1 2 5 4 3 6

height of tower: 6 15

Output :

1 2 3 & 4 5 6

Problem 4:

Given a 5X5 chess board as input. 9 knights are placed in the board. Print whether
the configuration valid or Invalid.

Problem 5:

Given a number, print all the code that can be formed with z={a=1, .., z=26}.

1123

{1, 1, 2, 3} = aabc

{11, 2, 3} = kbc

{1, 1, 23} = aaw

{11, 23} = kw
----------------------------------------------
39)
1. Pangram Checking
Check whether all english alphabets are present in the given sentence or not
I/P: abc defGhi JklmnOP QRStuv wxyz
O/P: True

I/P: abc defGhi JklmnOP QRStuv


O/P: False

2. Password Strength
Find the strength of the given password string based on the conditions
Four rules were given based on the type and no. of characters in the string.
Weak – only Rule 1 is satisfied or Rule 1 is not satisfied
Medium – Two rules are satisfied
Good – Three rules satisfied
Strong – All Four rules satisfied
I/P: Qw!1 O/P: Weak
I/P: Qwertyuiop O/P: Medium
I/P: QwertY123 O/P: Good
I/P: Qwerty@123 O/P: Strong

3. First Occurrences
Given two strings, find the first occurrence of all characters of second string in
the first string and
print the characters between the least and the highest index

I/P: ZOHOCORPORATION PORT


O/P: OHOCORPORAT

Explanation: The index of P in first string is 7, O is 1, R is 6 and T is 11. The


largest range is 1 – 11.
So print the characters of the first string in this inex range i.e. OHOCORPORAT

4. Matrix Diagonal sum


Given a matrix print the largest of the sums of the two triangles split by diagonal
from top right to bottom left
I/P:

3 3
1 2 3
4 5 6
7 8 9

O/P: 38

5. Matrix Addition
Given n integer arrays of different size, find the addititon of numbers represented
by the arrays
I/P: 4
3 5 4 2
2 4 5
4 5 6 7 8
4 9 2 1
1 2
O/P: 50856

6. Cricket Scores
Given a timeline of scores, find the individual scores of player 1 and player 2 and
Extras
W – Wide N – No Ball . – Dot Ball
Consider the game starts from player 1
I/P:

1 . 2 . 4 3 6 W 1 . N . 2 1
O/P:

P1 – 8
P2 – 12
Extras – 2

7. Queries
R A B C
1 56 67 89
2 89 54 90
3 78 91 83
4 69 72 95
R – Rollno, A, B, C – Marks in three subjects
Given the above matrix, print the result of the queries given the following syntax.
The first input string has a single character denoting the field to be printed.
* – All fields of the selected rows
A – Print only field A
B – Print only field B
C – Print only field C

The second string contains the condition – <field><relational_operator><value>.


> – Greater than
< – Less than
= – Equal to

I/P: *
A>70

O/P:

2 89 54 90
3 78 91 83
4 69 72 95

I/P: A
C<90

O/P:

56
78

8. Count Possible Paths


Given a N*N binary matrix and the co-ordinate points of start and destination, find
the number of possible path between them.
I/P:
4
1 0 0 1
1 0 1 0
1 1 1 0
0 1 1 1

1 2 (start position)
0 0 (destination)
O/P: 2

I/P:
4
1 0 0 1
1 0 1 0
1 1 1 0
0 1 1 1

2 0 (start position)
3 3 (destination)
O/P: 2
9. Shuffle an Array
Given a range of numbers print the numbers such that they are shuffled
First line contains no. of test cases.
I/P:
3
1 10
5 12
1 10

O/P: (The order of numbers may vary)


2 3 9 5 1 10 6 7 8 4
5 6 9 12 10 11 7 8
9 5 1 2 3 4 8 7 6 10

If any of the given ranges are same, The orders of the numbers must vary.
I/P: 4
1 7
1 7
1 7
1 7
O/P:
6 7 1 5 2 3 4
1 7 2 6 3 5 4
6 3 5 1 4 2 7
1 2 3 6 5 7 4

Around thirty students were selected for next round.


--------------------------------------------------
40)
1) Wildcard Pattern Matching https://www.geeksforgeeks.org/wildcard-pattern-
matching/

2) https://www.geeksforgeeks.org/number-cells-queen-can-move-obstacles-chessborad/

3) https://www.geeksforgeeks.org/job-sequencing-problem-set-1-greedy-algorithm/

4) https://www.geeksforgeeks.org/word-ladder-length-of-shortest-chain-to-reach-a-
target-word/

5) There are ‘n’ ants on a ‘n+1’ length rod. The ants are numbered from 1 to n and
are initially placed at positions starting from position 1 till position n. They
are moving either in left direction (denoted by ‘-1’) or in the right direction
(denoted by ‘1’). Whenever an ant crosses the boundary of the rod it falls off the
rod. You are given the initial direction of the ants. Now, whenever two ants
collide their direction switches, i.e. the ant going in left direction (‘-1)
changes it’s direction towards right (‘1’) and the ant going in the right direction
(‘1’) changes it’s direction towards left (‘-1’). Find last ant to fall off the
rod.

Note: In case two ants are falling simultaneously in the end print the index of the
lower indexed ant.

Input:
2
2
1 1
8
1 1 -1 1 1 1 -1 1

Output:
1
3
------------------------------------------------
41)
Sort the given elements in decending order based on the number of factors of each
element – Solution 1
Find whether the given number is palindrome or not. Don’t use arrays or strings
Reverse the given string keeping the position of special characters intact
Find the shortest path from one element to another element in a matrix using right
and down moves alone. The attached solution uses moves in all directions. –
Solution 4
Pattern
-----------------------------------------------------
42)
https://www.geeksforgeeks.org/find-number-currency-notes-sum-upto-given-amount/
https://www.geeksforgeeks.org/number-cells-queen-can-move-obstacles-chessborad/
https://www.geeksforgeeks.org/program-to-convert-hexadecimal-number-to-binary/
https://www.geeksforgeeks.org/convert-binary-number-hexadecimal-number/
------------------------------------------
Q.no.1) Given N. print the following snake pattern (say N = 4). condition: must
not use arrays ( 1D array or 2D array like Matrix ).

1 2 3 4

8 7 6 5

9 10 11 12

16 15 14 13

Q.no.2) Given N. print the Latin Matrix (say N = 3). condition: must not use
strings(aka character literals), arrays (both 1D and 2D), inbuilt functions(like
rotate).

A B C

B C A

C A B

Q.no.3) Given a number N. find the minimum count of numbers in which N can be
represented as a sum of numbers x1, x2, … xn. where xi is number whose digits are
0s and 1s.

example 1) i/p : N = 33

o/p : count = 3. 33( 11 + 11 + 11 )

some other possibilities of 33 is (11 + 11 + 10 + 1), (11 + 10 + 10 + 1 + 1 ),


(10 + 10 + 10 + 1 + 1 + 1)

Q.no.4) Finding all permutations of a string. ( backtracking approach ).

Q.no.5) Given an array of integers, write a program to re-arrange the array in


the given form.

1st_largest, 1st_smallest, 2nd_largest, 2nd_smallest, 3rd_largest ……. etc.

-----------------------------------------------
Q.no.1 ) Given a string find all possible subsets of the string ( power set of
the string ). string = “ABC” { “” , “A”, “B”, “C”, “AB”, “BC”, “AC”, “ABC” }

Q.no.2) Print chess board in form of 0’s and 1’s

0 1 0 1 0 1 0 1

1 0 1 0 1 0 1 0

0 1 0 1 0 1 0 1

1 0 1 0 1 0 1 0

0 1 0 1 0 1 0 1

1 0 1 0 1 0 1 0

0 1 0 1 0 1 0 1

1 0 1 0 1 0 1 0

Q.no.3) Compression of a given string.

example: aaaabbcccc —> a4bbc4

abbccc —> abbc3

bb —> bb (not b2, no need to compress)

Q.no.4) Given name, company, contacts. serialie the data to create a JSON file
(in form of string).

given: { “name”, “company”, “{ contacts_list }” }, output should exactly looks


like below (with proper indentation and spaces, parentheses, brackets )

“name” : “Karthick”,

“company” : “Zoho Corporation”,

“contacts” : [
{

“name” : “person1”,

“email” : “person1@gmail.com”,

“phone” : “1234567890”

},

“name” : “person2”,

“email” : “person2@gmail.com”,

“phone” : “1234567890”

},

“name” : “person_n“,

“email” : “person_n@gmail.com”,

“phone” : “1234567890”

},

Q.no.5 ) Design Zoho Invoice Model(using c, c++, java). Design should work for the
following HTTP commands for the corresponding invoices and customers.

GET customers | GET customers/{ customer_id }


GET invoices | GET invoices/ { invoice_id }
iii. POST customers/{ customer_id } { body }

POST invoices/ { invoice_id } { body }


----------------------------------------------
Convert integer to binary (using recursive).
Reverse the string without disturbing the vowels and space.
Get the repeated numbers in the array
On problem related to merge sort.
On problem related to linked list where asked.
-------------------------------------------------
1. -1 represents ocean and 1 represents land find the number of islands in the
given matrix.

Input: n*n matrix

1 -1 -1 1
-1 1 -1 1
-1 -1 1 -1
-1 -1 -1 1
Output: 2 (two islands that I have
bold in matrix at 1, 1 and 2, 2)
2. Print all the possible subsets of array which adds up to give a sum.

Input: array{2, 3, 5, 8, 10}


sum=10
Output: {2, 3, 5}
{2, 8}
{10}
3. There is a circular queue of processes. Every time there will be certain no of
process skipped and a particular start position. Find the safe position.

Input: Number of process:5


Start position:3
Skip: 2nd
Output: 1 will be the safest position
(Logic: 1 2 3 4 5 starting from 3, 5th process will be skipped
1 2 3 4 5 process 2 will be skipped
1 2 3 4 5 process 4 will be skipped
1 2 3 4 5 process 3 will be skipped, so safest process is 1.
Here I was able to solve two questions and was selected for third round. Those who
were not able to solve but are still good at explaining logic then they were
considered for debugging team and went for further rounds. But this won’t happen
every time. Only if they see any potential inside you to work for them sincerely
they may consider you for other teams or else you are rejected at that point
itself.
-----------------------------------------------------
Reverse the path from root node to the leaf node in the tree
Given an array of values persons[], each represents the weight of the persons.
There will be infinite bikes available. Given a value K which represents the
maximum weight that a bike accommodates. Along with that one more condition, a bike
can carry two persons at a time. You need to find out the least number of times,
the bike trips are made.
Assume there exists infinite grid, you’re given initial position x, y. Inputs will
be movements either L or R or U or D. After n inputs, you need to give the current
position.
Input:
4 5 //initial position x, y
9 //number of movements
U L R R D D U L R //7 movements
Output:
5 5
Given a matrix NxN, you are initially in the 0, 0 position. The matrix is filled
with ones and zeros. Value “one” represents the path is available, while “zero”
represents the wall. You need to find the can you able to reach the (N-1)x(N-1)
index in the matrix. You can move only along the right and down directions if
there’s “one” available.
Input:
5 //N value
1 0 1 0 0
1 1 1 1 1
0 0 0 1 0
1 0 1 1 1
0 1 1 0 1
Output:
Yes
Given an array of integers, compute the maximum value for each integer in the
index, by either summing all the digits or multiplying all the digits. (Choose
which operation gives the maximum value)
Input:
5
120 24 71 10 59
Output:
3 8 8 1 45
Explanation: For index 0, the integer is 120. Summing the digits will give 3, and
whereas Multiplying the digits gives 0. Thus, maximum of this two is 3.

They skipped the long coding round, and moved on to the F2F interviews, since only
few were met their expectations.
-----------------------
1.Maximum Sum Sub Array problem with slight modification(modification to Kadane’s
Algorithm – Dynamic Programming)

2.ATM system question where we have to withdraw cash and we need to update the
available cash in ATM

3.WildCard pattern matching question (Dynamic Programming)

4.Some simple question which is related to number crunching

5.Find the word in 2D grid of letters


---------------------------------------------
1.

Sample Input-

Hacker

Rank

Sample Output-

Hce akr

Rn ak

2.

Sample Input-

Print the word with odd letters – PROGRAM


Sample Output-
P P
R R
O O
G
R R
A A
M M
3.

Sample Input – Alternate Sorting

Input: {1, 2, 3, 4, 5, 6, 7}

output: {7, 1, 6, 2, 5, 3, 4}
--------------------------------------------
Q1. Print whether the version is upgraded, downgraded or not changed according to
the input given.

example: Input : Version1 4.8.2 Version2 4.8.4 Output: upgraded, Input : Version1
4.0.2 Version2 4.8.4 Output: downgraded

Q2. Print all possible subsets of the given array whose sum equal to given N.

example: Input: {1, 2, 3, 4, 5} N=6 Output: {1, 2, 3}, {1, 5}, {2, 4}

Q3. Reverse the words in the given String1 from the first occurrence of String2 in
String1 by maintaining white Spaces.

example: String1 = Input: This is a test String only String2 = st Output: This is a
only String test

Q4. calculate Maximum number of chocolates can eat and Number of wrappers left in
hand.

Money: Total money one has to spend.

Price: price per chocolate.

wrappers: minimum number of wrappers for exchange.

choco: number of chocolate for wrappers.

Max visit: Maximum number of times one can visit the shop.(if zero consider it
infinite)

example: input: Money:40 Price:1 wrappers:3 choco:1 Max visit:1 Output: total
chocolate can eat: 53 wrappers left in hand:14
------------------------------------------------
Remove the duplicates in the String.

Testcase 1:
Input: Java1234

Output: Javb1234 (Remove the second ‘a’ as it is duplicated)

Testcase 2:

Input: Python1223:

Output: Python1234 (Replace the second 2 with 3, and replace 3 with 4 as 3 is


replaced for the duplicated 2)

Testcase 3:

Input: aBuzZ9900

Output: aBuzC9012

(Replace the second ‘Z’ with ‘C’ as ‘a’ and ‘B’ are already there in the String.
Replace with capital C as the letter to be replaced is capital Z. The second 9
turns out to be zero and the zero turns out to ‘1’ and the second zero turns out to
‘2’)
---------------------------------------------
Count number of words, letters, tabs, newlines, whitespaces in the given text file.
Subset Sum Problem.
Count all possible paths from top left to bottom right
Given three strings s1,s2,s3.Remove commonly occurring words or sentences in all
the three strings.
The strings are:
s1 = "Everyday I do exercise if"
s2 = "Sometimes I do exercise if i feel stressed"
s3 = "Mostly I do exercise on morning"

Output:
s1 = "Everyday if"
s2 = "Sometimes if i feel stressed"
s3 = "Mostly on morning"

Wildcard Pattern Matching.


---------------------------------
This round consisted of 6 questions.

Given a Boolean matrix mat[M][N] of size M X N, modify it such that if a matrix


cell mat[i][j] is 1 then make its adjacent cells as 0.
Replace every element with the greatest element on right side
https://www.geeksforgeeks.org/replace-every-element-with-the-greatest-on-right-
side/
Equilibrium index of an array
https://www.geeksforgeeks.org/equilibrium-index-of-an-array/
Flood fill algorithm
https://www.geeksforgeeks.org/flood-fill-algorithm-implement-fill-paint/
Print matrix in zig-zag fashion
https://www.geeksforgeeks.org/print-matrix-zag-zag-fashion/
Diameter of a Binary Tree
https://www.geeksforgeeks.org/diameter-of-a-binary-tree/
The mentors were very much particular on the time and space complexity of the code.
--------------------------------------------
1. Pattern printing (diff : easy to med).
2. Paranthesis checker.

3. Make a palindrome by deleting or shuffling or swapping characters .

4. Modify an array such that every element should be greater than prev and next .

5. Wildcard pattern matching.


6.print a matrix in snake pattern k = 10, row = 3.

1 6 7

2 5 8

3 4 9 10
--------------------------------
1. Write a program to print a snake matrix in the following pattern without using
arrays and if conditions.

Input: 4

Output:

1 2 3 4
8 7 6 5
9 10 11 12
16 15 14 13
2. Write a program to find the duplicate numbers in an array and their occurrences.

Store the duplicate numbers in a separate array and print the output.

Input : [ 1, 2, 4, 5, 2, 1, 5, 2, 10, 22, 5 ]


Output:
1 -> 2
2 -> 3
5 -> 3
Section B: Explain logic then code

1. 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.

Input: "12345 * + - + "


Result: 6 [Explanation: 1 * 2 + 3 - 4 + 5 = 6]
Input: "374291 - - * + -"
Result: -8 [Explanation: 3 - 7 - 4 * 2 + 9 - 1 = -8]
2. For a given number N, find the next immediate palindrome number.

Input: 808
Output: 818
Input: 2133
Output: 2222
3. Write a program to implement Zeckendorf’s theorem.

Definition: Zeckendorf’s theorem states that every positive integer can be


represented uniquely as the sum of one or more distinct Fibonacci numbers in such a
way that the sum does not include any two consecutive Fibonacci numbers.

Example:

Input: 64
Output: 55+8+1
Input: 50
Output: 34+13+3
-----------------------------------
0)
1. Find the occurrence of a number and display the values in ascending order of the
given input

Ex input 3 4 3 4 1 2 3 1 2

Output 2 2 3 2

2.Alphabets are inside () and the number -9<=0>=9 which is under{} solve the string
according to the sample input output

Input (z){-2}oho

Output ZZoho

Input ((X){2}(y){3}(z)){2}

Output xxyyyzxxyyyz

3.a. email id can have alphabets numbers replace the email ID with 5 stars ()
should have domain name

Example input zoho@zoho.com

Output z@zoho.com

B. Phone number should have + at 1st and should have 2 numbers and a hypen – and 10
numbers 1st 6 numbers should replace with 5 stars..

In the 10 number can have – or () it can be negligible

Example input +91-1234567890

Output +91-7890

+91-(123)(234)(6789)

+91-6789

4. https://www.geeksforgeeks.org/sort-array-wave-form-2

5. https://www.geeksforgeeks.org/add-two-numbers-represented-by-two-arrays/
--------------------------------

You might also like