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

SDE - 1

TCS
upvote
share-icon
3 rounds | 5 Coding problems

Interview preparation journey

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

Tip 1 : Practice Atleast 250 Questions
Tip 2 : Do at least 2 projects

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

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

Interview rounds

01
Round
Medium
Online Coding Interview
Duration120 minutes
Interview date7 Aug 2021
Coding problem2

1. Prime Digit Sum

Hard
45m average time
70% success
0/120
Asked in companies
OracleCodenationTCS

Find the number of good numbers between two numbers ‘L’ and ‘R’ inclusive. A number is good if the sum of its digits is a prime number

Output the number of good numbers.

Example :
Input:
'L' = 15 and 'R' = 19
There is only 1 number between which is good,
16 = 1 + 6 = 7 (which is a prime number).
Problem approach

To optimize the above approach, the idea is based on the following observations:

Odd number – Even Number = Odd Number 
Odd number – Odd number = Even number 
2 is the only even prime number. 
Therefore, the problem reduces to check only for those pairs of prime numbers whose difference between the elements of the pair is equal to 2. 
Follow the steps below to solve the problem:

Initialize a variable, say cntPairs to store the count of pairs of prime numbers such that the difference between elements of each pair is also a prime number.
Initialize an array, say sieve[] to check if a number in the range [1, N] is a prime number or not.
Find all the prime numbers in the range [1, N] using Sieve of Eratosthenes.
Iterate over the range [2, N], and for each element in the given range, check if the sieve[i] and sieve[i – 2] are tru

Try solving now

2. Anagram Pairs

Moderate
30m average time
60% success
0/80
Asked in companies
AdobeThought WorksHSBC

You are given two strings 'str1' and 'str1'.


You have to tell whether these strings form an anagram pair or not.


The strings form an anagram pair if the letters of one string can be rearranged to form another string.

Pre-requisites:

Anagrams are defined as words or names that can be formed by rearranging the letters of another word. Such as "spar" can be formed by rearranging letters of "rasp". Hence, "spar" and "rasp" are anagrams. 

Other examples include:

'triangle' and 'integral'
'listen' and 'silent'
Note:
Since it is a binary problem, there is no partial marking. Marks will only be awarded if you get all the test cases correct. 
Try solving now
02
Round
Easy
Face to Face
Duration30 minutes
Interview date4 Sep 2021
Coding problem2

Basics on java and Data and data structures. Must focus on Binary Trees

1. Prime Number

Easy
0/40
Asked in companies
ShareChatBarracuda NetworksAVIZVA

Write a Program to check whether the given number N is prime or not.

For a given number N check if it is prime or not. A prime number is a number that is only divisible by 1 and itself.
Problem approach

The idea to solve this problem is to iterate through all the numbers starting from 2 to sqrt(N) using a for loop and for every number check if it divides N. If we find any number that divides, we return false. If we did not find any number between 2 and sqrt(N) which divides N then it means that N is prime and we will return True.

Try solving now

2. Binary Tree Pruning

Moderate
20m average time
80% success
0/80
Asked in companies
DunzoArcesiumProtium

You have been given a Binary Tree where the value of each node is either 0 or 1. Your task is to return the same Binary Tree but all of its subtrees that don't contain a 1 have been removed.

Note :

A subtree of a node X is X, plus every node that is a descendant of X.

For Example :

Look at the below example to see a Binary Tree pruning.
Input: [1, 1, 1, 0, 1, 0, 1, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]

alt text

Output: [1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1]

For example, the input for the tree depicted in the below image would be :

alt text

1
2 3
4 -1 5 6
-1 7 -1 -1 -1 -1
-1 -1

Explanation :

Level 1 :
The root node of the tree is 1

Level 2 :
Left child of 1 = 2
Right child of 1 = 3

Level 3 :
Left child of 2 = 4
Right child of 2 = null (-1)
Left child of 3 = 5
Right child of 3 = 6

Level 4 :
Left child of 4 = null (-1)
Right child of 4 = 7
Left child of 5 = null (-1)
Right child of 5 = null (-1)
Left child of 6 = null (-1)
Right child of 6 = null (-1)

Level 5 :
Left child of 7 = null (-1)
Right child of 7 = null (-1)

The first not-null node (of the previous level) is treated as the parent of the first two nodes of the current level. The second not-null node (of the previous level) is treated as the parent node for the next two nodes of the current level and so on.
The input ends when all nodes at the last level are null (-1).

Note :

The above format was just to provide clarity on how the input is formed for a given tree.

The sequence will be put together in a single line separated by a single space. Hence, for the above-depicted tree, the input will be given as:
1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1
Try solving now
03
Round
Easy
HR Round
Duration20 minutes
Interview date5 Sep 2021
Coding problem1

Basics HR Questions like behavioral questions and locations wise question.

1. Basic HR Questions

Introduce yourself

What is the biggest challenge you faced in the journey till now?

What would you do to create harmony among your team?

Here's your problem of the day

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

Skill covered: Programming

How do you remove whitespace from the start of a string?

Choose another skill to practice
Similar interview experiences
SDE - 1
2 rounds | 4 problems
Interviewed by TCS
0 views
0 comments
0 upvotes
SDE - 1
2 rounds | 2 problems
Interviewed by TCS
1116 views
0 comments
0 upvotes
SDE - 1
2 rounds | 3 problems
Interviewed by TCS
1261 views
0 comments
0 upvotes
SDE - 1
2 rounds | 10 problems
Interviewed by TCS
1294 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
5 rounds | 12 problems
Interviewed by Amazon
115097 views
24 comments
0 upvotes
company logo
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
58237 views
5 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Amazon
35147 views
7 comments
0 upvotes