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

GenC

Cognizant
upvote
share-icon
2 rounds | 5 Coding problems

Interview preparation journey

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

Tip 1 : Do not only read, practice!
Tip 2 : Take notes of your mistakes 
Tip 3 : give at least 1 hour every day

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

Tip 1 : Do not make spelling mistakes.
Tip 2 : Do not add false experiences and skills.

Interview rounds

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

MCQs-Aptitude + Quantitative
In a coding round, 2 questions came.

1. Split the given array into K sub-arrays

Hard
15m average time
85% success
0/120
Asked in companies
AmazonTata Consultancy Services (TCS)Cognizant

You’re given an array 'arr' of size 'n' and an integer 'k'.

Your task is to split 'arr' into 'k' sub-arrays such that the maximum sum achieved from the 'k' subarrays formed must be the minimum possible.

A subarray is a contiguous part of the array.

Return the minimum possible value of the maximum sum obtained after splitting the array into 'k' partitions.


Example:
Input: ‘arr’ = [1, 1, 2] and ‘k’ = 2 

Output: 2

Explanation: If we want to make two subarrays, there are two possibilities: [[1], [1, 2]] and [[1, 1], [2]]. We can see that the maximum sum of any subarray is minimized in the second case. Hence, the answer is 2, which is the maximum sum of any subarray in [[1, 1], [2]].


Problem approach

The first line contains the number of test cases, T = 1.

The first test case

Given

N = 4
A = [4, 3, 2, 3]
K = 2
Approach

Check all the possible partitions of the array and take the one which gives the maximum profit
Possible partitions are as follows [- (4) + (3 + 2 + 3), - (4 + 3) + (2 + 3), - (4 + 3 + 2) + (3)]
The profits of these possible partitions are as follows [8 - 4, 5 - 7, 3 - 9] = [4, -2, -6] hence the answer is 4.

Try solving now

2. Smallest Window

Moderate
10m average time
90% success
0/80
Asked in companies
ArcesiumHSBCCognizant

You are given two strings S and X containing random characters. Your task is to find the smallest substring in S which contains all the characters present in X.

Example:

Let S = “abdd” and X = “bd”.

The windows in S which contain all the characters in X are: 'abdd', 'abd', 'bdd', 'bd'. 
Out of these, the smallest substring in S which contains all the characters present in X is 'bd'. 
All the other substring have a length larger than 'bd'.
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. Path visiting all nodes

Hard
45m average time
55% success
0/120
Asked in companies
HCL TechnologiesTata Consultancy Services (TCS)Urban Company (UrbanClap)

You are given a connected undirected unweighted graph of ‘N’ nodes and ‘M’ edges, such that there is only one undirected edge between any two nodes and no self-loop. Your task is to find the length of the shortest path that visits all ‘N’ nodes at least once.

Note :

1) Here length of the path refers to the number of edges in that path.
2) You can start and stop at any node.
3) You can visit any node 0 or more times.
4) You can use any given edge 0 or more times.
Try solving now

2. Buy Maximum Stocks if ‘i’ stocks can be bought on ‘i-th’ day

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

You are given an array ‘prices’ of a stock and a number ‘amount’. Each element of the array/list prices, ‘prices[i]’ represent the price of the stock on the ‘i-th’ day. Your task is to buy the maximum number of stocks in ‘amount’ money. Every stock has an infinite supply.

Rule to buy a stock: On the ‘i-th’ day you can buy at max ‘i’ a number of stock and ‘i’ is ‘1’ based.

For example: Given ‘prices = {10, 7, 19}’, and ‘amount = 45’.

Buy 1- stock on the first day, 2-stocks on the second day, and 1-stock on the third day, so the total investment amount is ‘1 * 10 + 2 * 7 + 1 * 19 = 10 + 14+ 19 = 43’ so you can buy ‘4’ stock in ‘amount =45’.

Try solving now

3. Distinct islands

Moderate
25m average time
80% success
0/80
Asked in companies
SalesforceExpedia GroupCognizant

You are given a two-dimensional array/list of integers consisting of 0s and 1s. In the list, 1 represents land and 0 represents water.

The task is to find the number of distinct islands where a group of connected 1s(horizontally or vertically) forms an island.

Note:
Two islands are considered to be the same if and only if one island is equal to another(not rotated or reflected) i.e if we can translate one island on another without rotating or reflecting then it would be considered as the same islands. 
For example:
1 1 0
0 0 1
0 0 1

In this example, we have two islands and they would be considered as distinct islands as we can not translate them on one another even if they have the same no of 1's.
For example :
1 1 0 0 0 
1 1 0 0 0
0 0 0 1 1
0 0 0 1 1

In this example, we have two islands and they are the same as we can translate one island onto another island, so our answer should be 1.
Try solving now

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
2 rounds | 3 problems
Interviewed by Cognizant
1083 views
0 comments
0 upvotes
company logo
GenC
2 rounds | 5 problems
Interviewed by Cognizant
878 views
0 comments
0 upvotes
company logo
Program Analyst
2 rounds | 6 problems
Interviewed by Cognizant
604 views
0 comments
0 upvotes
company logo
Programmer Analyst Trainee
3 rounds | 8 problems
Interviewed by Cognizant
773 views
0 comments
0 upvotes