Você está na página 1de 3

Q1. w.a. function to print longest common substring.

input: tejsinghrana
singhranadayal
output: singhrana
Q2. w.a. function to print the unique characters in a string.
input: asmnasnagmgsalna
output: asmngl
Q3. Given an array of strings and each string have only two characters
e.g.
srt = {ab, cd, al, ep, st, pm}
you have to print only those strings which have second character next
of the first character.
i.e. ab + cd + al = abcd
Q4 Find the longest string in a string, which have characters in contigious
form.
e.g. input: abcdkljklmnopqjrjgs
output: lmnopq

interview Questions:
1. print the sequence:
4444
4333
4322
4321
Q2. We have an array containing only 0 and 1.Sort the array
with complexity of O(n).

Some questions normally asked in nagarro:


Q1. Function for Tic tac too game.
Q2. NQueen problem.
Q3. Function to print the permutations of a number.
Q4. You are given a array of words. You are also given a character array
which contains all the unique characters present in the first array
sorted in a special order.Assume all characters are in lowercase.
You have to sort the first array according to the order specified in
the second array.
For example
Arr1[][] = { cd , ef , pq , cg }
Arr2[] = { p , e , c , g , d , f , q }
Sorted array is
pq , ef , cg , cd
Q5 You are given a string. You have to find the longest increasing subsequence
of the string.
For example
Input: abcablogsd
Output: ablo
Q6. Every number has a Digital river associated to it; the next element in the
river is obtained by adding to the number, sum of its digits. For e.g.
River-8 is.
8->16->23->28->38...
8
8+8=16
16+ (1+7) =23
23+ (2+3) =28 and so on...
All rivers meet river-1, river-3 or river-9 at some point.
Given a Number find which river it meets.
Q7. You are given a n*n matrix. You can go upward, downward, left or right. No d
iagonal moves are allowed. You are given a starting location and the destination
. Also given is the cost of going in each cell.
You have to write a function which prints the path to the destination from the s
ource which has minimum cost and returns the minimum costs.
For example:
Given a 3*3 matrix
Find the shortest path between (0,0) to (2,2)
2 5 6
4 8 4
2 1 3

Q8. You are given two integers. You have to write a function to add their rever
sed equivalent
(i.e. the number with its digits reversed for ex 24 becomes 42) and return the r
everse of the sum.
Assume the reverse of 12 is 21 and not 210 or 2100
The prototype is: int AddReverse(int num1,int num2)
For example
Input : 24 35
Output : 59
Input: 227 872
Output: 1 ( And not 0001)
Input: 30 23
Output: 53 ( 3 + 32 = 35 so output 53)
Q9. print the sequence..
12345
23451
34512
45123
51234
Q 10. Find the longest common subsequence in two given string.
Q 11. Highest occurence of a character in a string and displaying it.
Q 12. We have some trees in a queue of given heights.We have to print only those
trees which
can be seen.
e.g. if we have trees of height in sequence 324165 then output will be 346
Q 13. Find the longest palandrom in a string
e.g. input: abfgerccdedccfgfer
output: ccdedcc
Q 14. Input a number and then find the next higher number such that for both the
number in
binarry representation contains equal number of 0s and 1s.
e.g. input: 3 ( 0000000000000011 )
output:5 ( 0000000000000101 )
Q 15. There are two sorted arrays a1 and a2 of sizw n1 and n2 respectively.
array a1 is full
array a2 has exactly n1 empty spaces.
write a function to merge these two arrays to form a sorted array without
any extra memory use.
Q 16. There is a matrix MxN. Its elements consist of either value equal to
0 or 1. If there is any zero in the row , then the output matrix should ha
ve all zeros in that row.
If there is any zero in any column then that column that column should
have all zeros in the output matrix. Find the function to perform
these operations.

Você também pode gostar