Cognizant interview experience Real time questions & tips from candidates to crack your interview

Genc Next

Cognizant
upvote
share-icon
2 rounds | 6 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 3 months
Topics: Data Structures, Pointers, OOPS, System Design, Algorithms, Dynamic Programming
Tip
Tip

Tip 1 - Practice At least 250 Questions of DS algo
Tip 2 - Do at least 2 application based projects
Tip 3 - Practice questions with optimized approaches

Application process
Where: Campus
Eligibility: 6.5 CGPA
Resume Tip
Resume tip

Tip 1 : Have some projects on resume.
Tip 2 : Do not put false things on resume.
Tip 3 : Project should clear and crisp

Interview rounds

01
Round
Easy
Online Coding Interview
Duration120 minutes
Interview date20 Oct 2021
Coding problem2

MCQs- Aptitude + Quantitative
2 questions came in coding round

1. Sort An Array of 0s, 1s and 2s

Easy
10m average time
90% success
0/40
Asked in companies
SamsungDirectiZS

You have been given an array/list 'arr' consisting of 'n' elements.


Each element in the array is either 0, 1 or 2.


Sort this array/list in increasing order.


Do not make a new array/list. Make changes in the given array/list.


Example :
Input: 'arr' = [2, 2, 2, 2, 0, 0, 1, 0]

Output: Final 'arr' = [0, 0, 0, 1, 2, 2, 2, 2]

Explanation: The array is sorted in increasing order.
Problem approach

Keep three indices low = 1, mid = 1 and high = N and there are four ranges, 1 to low (the range containing 0), low to mid (the range containing 1), mid to high (the range containing unknown elements) and high to N (the range containing 2).
Traverse the array from start to end and mid is less than high. (Loop counter is i)
If the element is 0 then swap the element with the element at index low and update low = low + 1 and mid = mid + 1
If the element is 1 then update mid = mid + 1
If the element is 2 then swap the element with the element at index high and update high = high – 1 and update i = i – 1. As the swapped element is not processed
Print the array.

Try solving now

2. Subarray With Given Sum

Moderate
15m average time
85% success
0/80
Asked in companies
SnapdealOlaAccenture

Given an array ARR of N integers and an integer S. The task is to find whether there exists a subarray(positive length) of the given array such that the sum of elements of the subarray equals to S or not. If any subarray is found, return the start and end index (0 based index) of the subarray. Otherwise, consider both the START and END indexes as -1.

Note:

If two or more such subarrays exist, return any subarray.

For Example: If the given array is [1,2,3,4] and the value of S is equal to 7. Then there are two possible subarrays having sums equal to S are [1,2,3] and [3,4].

Problem approach

Traverse the array from start to end.
From every index start another loop from i to the end of array to get all subarray starting from i, keep a variable sum to calculate the sum.
For every index in inner loop update sum = sum + array[j]
If the sum is equal to the given sum then print the subarray.

Try solving now
02
Round
Medium
Video Call
Duration30 minutes
Interview date11 Nov 2021
Coding problem4

Basic Hr Questions were asked. I was also asked about some questions from DS algo + from my projects. I was also asked questions from DBMS. I was also asked to solve some puzzle Questions

1. Spiral Matrix

Easy
0/40
Asked in companies
OYOJP MorganAdobe

You are given a N x M matrix of integers, return the spiral path of the matrix

Example Of Spiral Path

Spiral Path

Problem approach

Let the array have R rows and C columns. seen[r] denotes that the cell on the r-th row and c-th column was previously visited. Our current position is (r, c), facing direction di, and we want to visit R x C total cells.

As we move through the matrix, our candidate’s next position is (cr, cc). If the candidate is in the bounds of the matrix and unseen, then it becomes our next position; otherwise, our next position is the one after performing a clockwise turn.

Try solving now

2. Puzzle

Two students appeared at an examination. One of them secured 9 marks more than the other and his marks was 56% of the sum of their marks. The marks obtained by them are:


Let their marks be (x + 9) and x.

Then, x + 9 = 56/100 (x + 9 + x)

25(x + 9) = 14(2x + 9)

3x = 99

x = 33

So, their marks are 42 and 33.

3. Puzzle

Six bells commence tolling together and toll at intervals of 2, 4, 6, 8 10 and 12 seconds respectively. In 30 minutes, how many times do they toll together ?


L.C.M. of 2, 4, 6, 8, 10, 12 is 120.

So, the bells will toll together after every 120 seconds(2 minutes).

In 30 minutes, they will toll together 30 + 1 = 16 times.
2

4. Puzzle

Traveling at 3/4th of the original Speed a train is 10 minutes late. Find the usual Time taken by the train to complete the journey?


Let the usual Speed be S1 and usual Time be T1. As the Distance to be covered in both the cases is same, the ratio of usual Time to the Time taken when he is late will be the inverse of the usual Speed and the Speed when he is late

If the Speed is S2 = ¾S1 then the Time taken T2 = 4/3 T1 Given T2 – T1 = 10 =>4/3 T1 – T1 = 10 => T1 = 30 minutes.

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

To make an AI less repetitive in a long paragraph, you should increase:

Choose another skill to practice
Similar interview experiences
company logo
Genc Next
2 rounds | 5 problems
Interviewed by Cognizant
1249 views
0 comments
0 upvotes
company logo
Genc Next
2 rounds | 7 problems
Interviewed by Cognizant
1734 views
0 comments
0 upvotes
company logo
Genc Next
3 rounds | 6 problems
Interviewed by Cognizant
867 views
0 comments
0 upvotes
company logo
Genc Next
3 rounds | 9 problems
Interviewed by Cognizant
1064 views
0 comments
0 upvotes