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

Genc Next

Cognizant
upvote
share-icon
2 rounds | 7 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 Atleast 250 Questions
Tip 2 - Do atleast 2 projects

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

Tip 1 : Have some projects on resume.
Tip 2 : Do not put false things on resume.

Interview rounds

01
Round
Medium
Online Coding Interview
Duration120 minutes
Interview date11 Nov 2020
Coding problem2

1. Check If Linked List Is Palindrome

Easy
15m average time
85% success
0/40
Asked in companies
HSBCAmazonThought Works

You are given a Singly Linked List of integers. You have to return true if the linked list is palindrome, else return false.


A Linked List is a palindrome if it reads the same from left to right and from right to left.


Example:
The lists (1 -> 2 -> 1), (3 -> 4 -> 4-> 3), and (1) are palindromes, while the lists (1 -> 2 -> 3) and (3 -> 4) are not.
Problem approach

A simple solution is to use a stack of list nodes. This mainly involves three steps.
Traverse the given list from head to tail and push every visited node to stack.
Traverse the list again. For every visited node, pop a node from the stack and compare data of popped node with the currently visited node.
If all nodes matched, then return true, else false

Try solving now

2. Reverse the String

Easy
15m average time
85% success
0/40
Asked in companies
ThalesDeutsche BankPaytm (One97 Communications Limited)

You are given a string 'STR'. The string contains [a-z] [A-Z] [0-9] [special characters]. You have to find the reverse of the string.

For example:

 If the given string is: STR = "abcde". You have to print the string "edcba".
follow up:
Try to solve the problem in O(1) space complexity. 
Problem approach

We can do the above task by splitting and saving the string in a reverse manner

Try solving now
02
Round
Easy
Face to Face
Duration30 minutes
Interview date25 Nov 2020
Coding problem5

This was a technical + HR round.

1. Remove Duplicates

Easy
0/40
Asked in companies
CognizantPaytm (One97 Communications Limited)CIS - Cyber Infrastructure

Given a string S, remove consecutive duplicates from it recursively.

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

2. Isomorphic Strings

Easy
15m average time
85% success
0/40
Asked in companies
CognizantBarclaysCGI

You have been given two strings, 'str1' and 'str2'.


Your task is to return true if the given two strings are isomorphic to each other, else return false.


Note :
Two strings are isomorphic if a one-to-one mapping is possible for every character of the first string ‘str1’ to every character of the second string ‘str2’ while preserving the order of the characters.

All occurrences of every character in the first string ‘str1’ should map to the same character in the second string, ‘str2’.
For example :
If str1 = “aab” and str2 = “xxy” then the output will be 1. ‘a’ maps to ‘x’ and ‘b’ maps to ‘y’.

If str1 = “aab” and str2 = “xyz” then the output will be 0. There are two different characters in 'str1', while there are three different characters in 'str2'. So there won't be one to one mapping between 'str1' and 'str2'.
Problem approach

A Simple Solution is to consider every character of ‘str1’ and check if all occurrences of it map to the same character in ‘str2’. The time complexity of this solution is O(n*n).

An Efficient Solution can solve this problem in O(n) time. The idea is to create an array to store mappings of processed characters. 

1) If lengths of str1 and str2 are not same, return false.
2) Do following for every character in str1 and str2
a) If this character is seen first time in str1, 
then current of str2 must have not appeared before.
(i) If current character of str2 is seen, return false.
Mark current character of str2 as visited.
(ii) Store mapping of current characters.
b) Else check if previous occurrence of str1[i] mapped
to same character.

Try solving now

3. Puzzle

Two pipes A and B can fill a cistern in 37 minutes and 45 minutes respectively. Both pipes are opened. The cistern will be filled in just half an hour, if the B is turned off after:.

ans :-9 min

4. Puzzle

A train can travel 50% faster than a car. Both start from point A at the same time and reach point B 75 kms away from A at the same time. On the way, however, the train lost about 12.5 minutes while stopping at the stations. The speed of the car is:

ans :- 120 kmph

5. DBMS Question

what are acid properties?

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 | 6 problems
Interviewed by Cognizant
905 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