GFG App
Open App
Browser
Continue

# Cognizant Interview Experience (On Campus)

Round 1:Â  The first round of the Interview consisted of a basic Preliminary test on English, Aptitude, Logical Reasoning and a Coding section. We were asked to give the test from home with a WebCam enabled desktop. The coding part,

Question 1 (Time allocated for coding:20 mins) :

You are given a number n. You have to print ‘n’ numbers of an alternating sequence consisting of even and odd numbers.

Example: for n=10, the sequence will be: 2, 1, 4, 3, 6, 5, 8, 7, 10, 9

Question 2 (Time allocated: 30 mins):

Find the largest area in a set of rectangular bars.

Reference: https://www.geeksforgeeks.org/largest-rectangle-under-histogram/

Round 2: The second round of the Interview was a 1-on-1 F2F technical Interview. The interviewer was very polite and asked me for my resume. I am putting here the questions he asked me.

(I->Interviewer)

I: What are classes and objects ?

I: Scanner or BufferedReader and Why?

I: what is the use of static keyword ?

I: static classes and nested classes.

I: Do you know about the collection framework? Tell me about HashMap . Tell me about ArrayList, HashSet vs Treeset.

I: write code on try-catch-finally, throws.

Then came the Data Structure Questions:
I:Â  write the code for Binary search.

I: Given a set of numbers how would you find two numbers in O(n) time such that their sum is exactly n ? (I told him about the HashMap technique).

I: You are given an array ofÂ  numbers and some of them occur more than 1 time and not sorted. How would you print only the distinct numbers?

(1. You can use a count array, 2. You can use a HashSet )

He asked me to wait for the HR round.

Round 3: I was asked some basic HR questions,

1. Why cognizant? (almost all companies ask this question to find out how much a student knows about the company and how much interest does he hold)