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

Genc Next

Cognizant
upvote
share-icon
2 rounds | 5 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 3 months
Topics: Data Structures, DBMS , 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 application based projects on resume.
Tip 2 : Do not put false things on resume.
Tip 3 : Project should clear and crisp

Interview rounds

01
Round
Medium
Online Coding Interview
Duration120 minutes
Interview date13 Oct 2021
Coding problem2

MCQs- Aptitude + Quantitative 
2 questions came in coding round

1. Rat In a Maze All Paths

Moderate
40m average time
60% success
0/80
Asked in companies
MathworksExpedia GroupVisa

You are given a 'N' * 'N' maze with a rat placed at 'MAZE[0][0]'. Find and print all paths that rat can follow to reach its destination i.e. 'MAZE['N' - 1]['N' - 1]'. Rat can move in any direc­tion ( left, right, up and down).

Value of every cell in the 'MAZE' can either be 0 or 1. Cells with value 0 are blocked means the rat can­not enter into those cells and those with value 1 are open.

Problem approach

This question is solved by backtracking

Create a solution matrix, initially filled with 0’s.
Create a recursive function, which takes initial matrix, output matrix and position of rat (i, j).
if the position is out of the matrix or the position is not valid then return.
Mark the position output[i][j] as 1 and check if the current position is destination or not. If destination is reached print the output matrix and return.
Recursively call for position (i+1, j) and (i, j+1).
Unmark position (i, j), i.e output[i][j] = 0.

Try solving now

2. Remove Duplicates from Sorted Array

Easy
15m average time
85% success
0/40
Asked in companies
Tata Consultancy Services (TCS)Thought WorksGoldman Sachs

You are given a sorted integer array 'arr' of size 'n'.


You need to remove the duplicates from the array such that each element appears only once.


Return the length of this new array.


Note:
Do not allocate extra space for another array. You need to do this by modifying the given input array in place with O(1) extra memory. 


For example:
'n' = 5, 'arr' = [1 2 2 2 3].
The new array will be [1 2 3].
So our answer is 3.
Problem approach

Create an auxiliary array temp[] to store unique elements.
Traverse input array and one by one copy unique elements of arr[] to temp[]. Also keep track of count of unique elements. Let this count be j.
Copy j elements from temp[] to arr[] and return j

Try solving now
02
Round
Easy
Face to Face
Duration30 minutes
Interview date11 Nov 2021
Coding problem3

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

1. Quick Sort

Moderate
10m average time
90% success
0/80
Asked in companies
SamsungPaytm (One97 Communications Limited)Bank Of America

You are given an array of integers. You need to sort the array in ascending order using quick sort.

Quick sort is a divide and conquer algorithm in which we choose a pivot point and partition the array into two parts i.e, left and right. The left part contains the numbers smaller than the pivot element and the right part contains the numbers larger than the pivot element. Then we recursively sort the left and right parts of the array.

Example:

Let the array = [ 4, 2, 1, 5, 3 ]
Let pivot to be the rightmost number.

example

After the 1st level partitioning the array will be { 2, 1, 3, 4, 5 } as 3 was the pivot. After 2nd level partitioning the array will be { 1, 2, 3, 4, 5 } as 1 was the pivot for the left part and 5 was the pivot for the right part. Now our array is sorted and there is no need to divide it again.

Problem approach

The key process in quickSort is partition(). Target of partitions is, given an array and an element x of array as pivot, put x at its correct position in sorted array and put all smaller elements (smaller than x) before x, and put all greater elements (greater than x) after x. All this should be done in linear time.

Try solving now

2. 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?

Problem approach

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.

3. Puzzle

Two water tanks contain 250 and 400 litres of water respectively. What will be the maximum capacity of a bucket that can exactly measure the water in the two tanks?

Problem approach

Ans.
To find the maximum capacity of a bucket that can exactly measure the water in the two tanks, we have to find the HCF of 250 and 400.
Therefore, a 50 litre bucket has to be used to measure 250 and 400 litres of water exactly.

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 | 6 problems
Interviewed by Cognizant
905 views
0 comments
0 upvotes
company logo
Genc Next
2 rounds | 7 problems
Interviewed by Cognizant
1733 views
0 comments
0 upvotes
company logo
Genc Next
3 rounds | 6 problems
Interviewed by Cognizant
866 views
0 comments
0 upvotes
company logo
Genc Next
3 rounds | 9 problems
Interviewed by Cognizant
1063 views
0 comments
0 upvotes