Tata consultancy services Ltd interview experience Real time questions & tips from candidates to crack your interview

SDE - 1

Tata consultancy services Ltd
upvote
share-icon
2 rounds | 3 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 4 Months
Topics: Data Structures, System Design, Algorithms, Dynamic Programming, Operating System,Computer Networks, C, C++, Java
Tip
Tip

Tip 1 : Be thoroughly prepared OS and Networking in depth
Tip 2 : Practice mock interview before the actual interview
Tip 3 : Add at least two projects to your resume

Application process
Where: Campus
Eligibility: No back logs
Resume Tip
Resume tip

Tip 1 : Having core CS projects are good 
Tip 2 : Make it a simple and one-page resume.
Tip 3 : Use Proper fonts in your resume
Tip 4 : Be prepared for all the topics you have mentioned in your resume

Interview rounds

01
Round
Easy
Online Coding Interview
Duration60 Minutes
Interview date8 Sep 2021
Coding problem2

Timing(1 PM IST)
Test was taken on the hackerrank platform. In this test there were 20 MCQs based on compute fundamentals and 2 coding questions

1. Reverse Words In A String

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

You are given a string 'str' of length 'N'.


Your task is to reverse the original string word by word.


There can be multiple spaces between two words and there can be leading or trailing spaces but in the output reversed string you need to put a single space between two words, and your reversed string should not contain leading or trailing spaces.


Example :
If the given input string is "Welcome to Coding Ninjas", then you should return "Ninjas Coding to Welcome" as the reversed string has only a single space between two words and there is no leading or trailing space.
Problem approach

One idea for the solution is:

1) Reverse the whole string.

2) Then reverse the individual words.



For example, if the input is:

s = "Have a nice day!"

1) Then first reverse the whole string, 

s = "!yad ecin a evaH"

2) Then reverse the individual words,

s = "day! nice a Have"

Time Complexity:
O(n).

The first pass over the string is obviously O(n/2) = O(n). The second pass is O(n + combined length of all words / 2) = O(n + n/2) = O(n), which makes this an O(n) algorithm.

Auxiliary Space used:
O(1).

Space Complexity:
O(n).


// -------- START --------

/*
Suppose s = "abcdefgh" and we call reverse_string(s[2], 4) then this function will reverse "cdef" 
part of "abcdefgh". 
*/
void reverse_string(char *str, int len)
{
for(int i = 0; i < len / 2; i++)
{
swap(str[i], str[len - 1 - i]);
}
}

string reverse_ordering_of_words(string s)
{
int len = s.length();
// Reverse whole string.
reverse_string(&s[0], len);
int word_beginning = 0;
// Find word boundaries and reverse word by word.
for(int word_end = 0; word_end < len; word_end++)
{
if(s[word_end] == ' ') 
{
reverse_string(&s[word_beginning] , word_end - word_beginning);
word_beginning = word_end + 1;
}
}
/* 
If there is no space at the end then last word will not be reversed in the above for loop. 
So need to reverse it. 
Think about s = "hi". 
Reverse the last word.
*/
reverse_string(&s[word_beginning], len - word_beginning);
return s;
}

// -------- END --------

Try solving now

2. K Largest Element

Moderate
10m average time
90% success
0/80
Asked in companies
Tata Consultancy Services (TCS)AmazonWalmart

You are given an unsorted array containing ‘N’ integers. You need to find ‘K’ largest elements from the given array. Also, you need to return the elements in non-decreasing order.

Problem approach

We need to preserve the order of elements in a sorted manner. If we can do that, we can obtain top K elements. Also, if an element is smaller than the last element in top k, then that element can be dropped as we are not deleting elements.

We can maintain a balanced BST or a sorted set collection. Keep adding new elements to the sorted set and if the size of the tree increases more than k, remove the smallest element.

Time Complexity: 
O(N*log(K))

Space Complexity: 
O(K)

Try solving now
02
Round
Easy
Video Call
Duration60 Minutes
Interview date30 Sep 2021
Coding problem1

It was the technical Interview and questions were based on DBMS, OS, Networking, and Data structures and one coding question

1. Find Minimum Number Of Coins

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

Given an infinite supply of Indian currency i.e. [1, 2, 5, 10, 20, 50, 100, 500, 1000] valued coins and an amount 'N'.


Find the minimum coins needed to make the sum equal to 'N'. You have to return the list containing the value of coins required in decreasing order.


For Example
For Amount = 70, the minimum number of coins required is 2 i.e an Rs. 50 coin and a Rs. 20 coin.
Note
It is always possible to find the minimum number of coins for the given amount. So, the answer will always exist.
Problem approach

We will follow the following recursive definition:

If value == 0:

// Zero coins are required to express the value of 0.

// End of recursion. Base case.

return 0

If value > 0:

minimum_coins(value) = min {1 + minimum_coins(value-coins[i])} (where i belongs to [0,n-1] and coins[i]



Basically what we are doing here is exhaustively searching for all the possible combinations of denominations which can generate our desired value and maintain a minimum number of coins required to generate that value and that will be our answer.

This method is not efficient as it computes subproblems again and again.

Time Complexity:
O(n^value).

Auxiliary Space Used:

O(value). That’s the maximum number of the recursive calls at a time.

Space Complexity:
O(n + value).

Input takes O(n) and the auxiliary space used is O(value).

int minimum_coins(vector &coins, int value) {
// If value is zero return 0.
if (value == 0) {
return 0;
}
// Maximum value assigned initially
int global_min=100005;
for(int i=0; i < coins.size(); i++){
if (coins[i] <= value) {
// To find minimum coins required to make remaining value-coins[i]
int local_min=minimum_coins(coins, value-coins[i]);
// local_min number of coins required to make remaining value-coins[i] and 
// 1 coin with value coins[i] used.
if (local_min+1 < global_min) {
global_min=local_min+1;
}
}
}
// Return maintained global minimum value
return global_min; 
}

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

Which SQL clause is used to specify the conditions in a query?

Choose another skill to practice
Similar interview experiences
SDE - 1
2 rounds | 3 problems
Interviewed by Tata consultancy services Ltd
0 views
0 comments
0 upvotes
SDE - 1
2 rounds | 2 problems
Interviewed by Tata consultancy services Ltd
1081 views
0 comments
0 upvotes
SDE - 1
2 rounds | 3 problems
Interviewed by Tata consultancy services Ltd
1122 views
0 comments
0 upvotes
company logo
SDE - Intern
1 rounds | 3 problems
Interviewed by Amazon
3068 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
5 rounds | 12 problems
Interviewed by Amazon
113895 views
24 comments
0 upvotes
company logo
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
57277 views
5 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Amazon
34687 views
6 comments
0 upvotes