# Nagarro Technical Test Questions

Posted on :05-04-2016

Q1. Given an array, separate positives and negatives.

For eg. Input array - [9, 4, -3, -2, 1, -1, 5, 7, -9, -5]
Output array - [9,4,1,5,7,-3,-2,-1,-9,-5]

Q2. Define a function int[] reverse (int a[], int n) to reverse the first n elements of the integer array a.
Eg reverse ([2,5,3,4], 3) should give output [3,5,2,4]
Use constant memory and O(n) complexity.

Q3. Produce a matrix of N order such that

a[][]={
1 2 3
2 1 2
3 2 1
}

Q4. Write a program to find subsets that contains equal sum in an array:

for eg{1,2,3,4,2}->{1,2,3}&&{4,2}
{1,1,3,3,2,8}->{1,3,3,2}&&{1,8}
{1,3,4,7}->no subset

Q5.
int arr[]={2,2,2,3,3,5,6,7,8}

Sorted Array was Given. You have to construct

Function int[] RemoveDuplicate (int [] );
such that arr[] becomes {2,3,5,6,7,8}

Q6. Write a function such that String

INPUT: s = [abc]

a) OUTPUT: TRUE s = {abc}
b) OUTPUT: TRUE s = [{abc]
c) OUTPUT: False s = [(abc])
d) OUTPUT: False

Hence you have to construct a function that makes pair of round brackets, square brackets, curly brackets. Here closing of bracket must be in same order.

Q7. You are given a m x m matrix. Write a function to rotate submatrix within the matrix by 90 degree clock wise. Function takes x and y as starting row and column coordinate of matrix and N as size of submatrix as argument. Inplace rotation was required. I gave brute force i.e. With extra memory.

Q8. An array was given like

a[]={1,2,3,4,5,6}
int N=4,

now write a function name reverse (a[],n)

Q9. Write a function

void print MATCHFormatString (string sentence1, string sentence2) { }
Sentence 1: How are you david?
Sentence 2: David you may ea.

Now you have to remove .,?, ,! from both sentences and print out the matching substring in both sentences

Q10. Counting in Lojban, an artificial language developed over the last fourty years, is easier than in most languages.
The numbers from zero to nine are:

0  no
1  pa
2  re
3  ci
4  vo
5  mk
6  xa
7  ze
8  bi
9  so

Larger numbers are created by gluing the digit together.

For Example 123 is pareci
Write a program that reads in a lojban string(representing a no less than or equal to 1,000,000) and output it in numbers.

Q11. Write a program to print:

1 2 3 4 5
2 1 2 3 4
3 2 1 2 3
4 3 2 1 2
5 4 3 2 1

Q12.   Write a function

char[] GenerateNextDate (char[])

such that if a date of the format 23 Jan 2012 is input, the next date should be produced.

Eg: Input - 12 Dec 1987
Output - 13 Dec 1987

Q13. Given two file paths input File Path and output File Path, write a function void Remove Comments (char input File Path[], char output File Path[]) such that the contents of file referred by input File Path are copied to the file given by output File Path after removing the comments. In other words, first file contains a C program which should be copied to the second file excluding the comments.

Q14. Where now stands that small knot of villages known as the Endians, a mighty forest once stood. Indeed, legand has it that you could have stood on the edge of the wood and seen it stretch out for miles, were it not for the trees getting in the way.

In one section of the forest, the trees stood in a row and were of height from 1 to n, each height occurring once and once only.

A tree was only visible if there were no higher trees before it in the row.

For example, if the heights were 324165, the only visible trees would have been those of height 3, 4 & 6.

Write a Program that takes an array of integers representing the heights of the trees in the row as input and prints the list of the visible trees.

FreshersLive - No.1 Job site in India. Here you can find latest 2018 government as well as private job recruitment notifications for different posts vacancies in India. Get top company jobs for both fresher and experienced. Job Seekers can get useful interview tips, resume services & interview Question and answer. Practice online test free which is helpful for interview preparation. Register with us to get latest employment news/rojgar samachar notifications. Also get latest free govt and other sarkari naukri job alerts daily through E-mail.

 ✖