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

Frontend Developer

Cognizant
upvote
share-icon
3 rounds | 7 Coding problems

Interview preparation journey

expand-icon
Journey
I began my journey by studying DSA in college and learning programming languages such as Java and C++. I also gained practical experience through internships and personal projects.
Application story
After my resume was shortlisted, an HR representative contacted me through LinkedIn regarding the job opening. The subsequent interview process involved three rounds: an online coding round, a video call coding round, and an HR round.
Why selected/rejected for the role?
I passed all three rounds of interviews, and the next day, I got a confirmation letter. After seven days, I got an offer letter from the company.
Preparation
Duration: 6 months
Topics: OOPS, DBMS, CN, Data structures, Algorithms, CPP, OS
Tip
Tip

Tip 1: Work on projects and gain some experiences.
Tip 2: Solve coding questions as much as you can.

Application process
Where: Referral
Eligibility: No criteria
Resume Tip
Resume tip

Tip 1: Have some practical projects but include those only that you are confident about it.
Tip 2: Put your skill set which matches the applied role.

Interview rounds

01
Round
Medium
Online Coding Test
Duration60 minutes
Interview date3 Jul 2022
Coding problem2

1. Maximum Product Subarray

Moderate
25m average time
75% success
0/80
Asked in companies
AmazonMicrosoftSamsung

You are given an array “arr'' of integers. Your task is to find the contiguous subarray within the array which has the largest product of its elements. You have to report this maximum product.

An array c is a subarray of array d if c can be obtained from d by deletion of several elements from the beginning and several elements from the end.

For e.g.- The non-empty subarrays of an array [1,2,3] will be- [1],[2],[3],[1,2],[2,3],[1,2,3]. 
For Example:
If arr = {-3,4,5}.
All the possible non-empty contiguous subarrays of “arr” are {-3}, {4}, {5}, {-3,4}, {4,5} and {-3,4,5}.
The product of these subarrays are -3, 4, 5, -12, 20 and -60 respectively.
The maximum product is 20. Hence, the answer is 20.
Follow Up:
Can you solve this in linear time and constant space complexity?
Problem approach

Step 1: Run a nested for loop to generate every subarray.
Step 2: Calculate the product of the elements in the current subarray.
Step 3: Return the maximum of these products calculated from the subarrays.

Try solving now

2. Valid Pairs

Easy
22m average time
80% success
0/40
Asked in companies
AdobeAmazonCognizant

You are given an array 'ARR' of 'N' integers and two integers 'K' and 'M'.

You need to return true if the given array can be divided into pairs such that the sum of every pair gives remainder 'M' when divided by 'K'. Otherwise, you need to return false.

For example:

If the given array is [2, 1, 5, 7] and K = 9 and M = 3. Then you need to return true because we can divide the array into two pairs, i.e (2, 1) and (5, 7) whose sums are 3 and 12, which when divided by 9 gives remainder 3, thus it is possible to divide the given array into pairs.  

Note:

Every element of the array should contribute to only one pair, i.e if the array is [3, 0, 0] and K = 2 and M = 1, then you need to return false, as element 3 will make a pair with any one of the 0. 
Problem approach

I asked for some clarification on whether I should print all distinct x's or if I should print an x when a pair of +x and -x is encountered. The first approach I suggested was to use a map and keep a flag for +x and -x if they were found once. Later, he asked me to print all pairs, so I stored the frequencies of all the elements in the map and iterated through the negative elements. For each element x, I would print x min(count[-x], count[+x]) times. He said he couldn’t afford that much space and wanted me to optimize space further. So I proposed a two-pointer approach where I sort the array once and then keep two pointers at the start and end. I would move the start pointer forward if the sum is less than 0, and I would move the end pointer backward if the sum is greater than 0. He was fine with the solution and asked me to code it on paper. I wrote the code and walked him through it.

Try solving now
02
Round
Medium
Video Call
Duration60 minutes
Interview date10 Jul 2022
Coding problem2

1. Row with Maximum 1's

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

You have been given a non-empty grid ‘mat’ with 'n' rows and 'm' columns consisting of only 0s and 1s. All the rows are sorted in ascending order.

Your task is to find the index of the row with the maximum number of ones.

Note: If two rows have the same number of ones, consider the one with a smaller index. If there's no row with at least 1 zero, return -1.


Example:

Input: 'n' = 3, 'm' = 3, 'mat' = [[1, 1, 1], [0, 0, 1], [0, 0, 0]]

Output: 0

Explanation: The row with the maximum number of ones is 0 (0 - indexed).
Problem approach

Since the array was sorted, the first thing that came to mind was running a binary search on each row. However, a closer look would show that once you know that for some row, values after column y are all 1, then from the next row, you don't need to check columns beyond y. You only need to check columns before y.

Try solving now

2. First non repeating character

Easy
15m average time
80% success
0/40
Asked in companies
QuikrAmazonWalmart

Ninja is now bored with numbers and is now playing with characters but hates when he gets repeated characters. Ninja is provided a string, and he wants to return the first unique character in the string.The string will contain characters only from the English alphabet set, i.e., ('A' - 'Z') and ('a' - 'z'). If there is no non-repeating character, print the first character of the string. If there is no non-repeating character, return the first character of the string.

Problem approach

The idea is to use a DLL (Doubly Linked List) to efficiently get the first non-repeating character from a stream. The DLL contains all non-repeating characters in order; that is, the head of the DLL contains the first non-repeating character, the second node contains the second non-repeating character, and so on.

Try solving now
03
Round
Easy
HR Round
Duration25 minutes
Interview date10 Jul 2022
Coding problem3

1. Basic HR Questions

Tell me about yourself.

Problem approach

Tip 1: Do not ask the interviewer what they want to know about you. You may be asking genuinely, but it can come across as rude.

Tip 2: Don’t panic, as it won’t help you impress the HR in this situation.

Tip 3: Avoid repeating what is already on your resume. The interviewer wants to learn about things not mentioned in the resume. Also, avoid discussing personal matters.

Tip 4: Introduce yourself using adjectives such as problem-solving, innovative, tech-savvy, creative, quick learner, etc., that best describe you in your professional life to boost your chances.

2. Basic HR Question

Why are you not interested in business, considering that your family is a business family?

Problem approach

Tip 1: I told them that I want to make my own life and do it by myself.
Tip 2: I also made them feel that I have self-learning ability.

3. Basic HR Questions

Why are you interested in this position?

Problem approach

Tip 1: HR professionals are likely trying to get you to reiterate your strengths and highlight your passion for both the company and the role. Talk about your past experiences and how they apply to this job, and link what you’re saying back to what they’ve said and to the job description.

Tip 2: Don’t panic, and express your interest in both the field and the company.

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
Programmer Analyst Trainee
2 rounds | 3 problems
Interviewed by Cognizant
1409 views
0 comments
0 upvotes
company logo
Genc Next
2 rounds | 7 problems
Interviewed by Cognizant
1734 views
0 comments
0 upvotes
company logo
Data Engineer
3 rounds | 6 problems
Interviewed by Cognizant
2469 views
0 comments
0 upvotes
company logo
Programmer Analyst
3 rounds | 8 problems
Interviewed by Cognizant
952 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
Frontend Developer
2 rounds | 1 problems
Interviewed by Tata Consultancy Services (TCS)
1986 views
1 comments
0 upvotes
Frontend Developer
2 rounds | 4 problems
Interviewed by Genpact
2268 views
0 comments
0 upvotes
Frontend Developer
3 rounds | 7 problems
Interviewed by Genpact
1715 views
0 comments
0 upvotes