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

SDE - 1

Tata1mg
upvote
share-icon
1 rounds | 3 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 12 Months
Topics: DSA , OOPS , OS, CN, Algorithms, DBMS , Dynamic Programming , Graphs
Tip
Tip

Tip 1 : Do DSA
Tip 2 : Do Extra Subjects
Tip 3 : Prepare some Projects

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

Tip 1 : Do Mention coding profiles in resume
Tip 2 : Do add summary of Projects

Interview rounds

01
Round
Easy
Online Coding Test
Duration60 Minutes
Interview date5 Jan 2022
Coding problem3

there were 3 coding questions
1. String
2. Trees
3. Greedy

1. Longest Repeating Non-Overlapping Substring.

Easy
0/40
Asked in company
Tata1mg

You are given a string ‘str’, you need to find the longest repeating and non-overlapping substring in the given string.

A substring of a string can be defined as a contiguous subsequence of that string. In other words, a string X is said to be a substring of the string S if X = S[a...b] = S[a]S[a+1]…..S[b] and 0 <= a <= b <= len(S) (0-based indexing).

You can return any such substring if more than one such substring exists in the string. If there is no such substring, return -1.

Note:

1. Repeating substrings in a string means those substrings which occur more than once in a string. For example, in the string “abaaba”, substrings “a”, “b”, “ab”, “ba”, “aba” are repeating.

2. Two substrings are called Non-overlapping substrings, if the intersection of all the indices of first substring i.e. [L1, R1] where L1 and R1 are the starting and ending index of the first substring respectively, and indices of the second substring i.e. [L2, R2] where L2 and R2 are the starting and ending indices respectively of the second substring, is NULL.

3. For example, in the string “abaaba”, two non-overlapping strings are “ab” lying in the interval [0, 1] (0-based indexing) and “aba” lying in the interval [3, 5] (0-based indexing). 
Problem approach

The problem can be solved easily by taking all the possible substrings and for all the substrings check it for the remaining(non-overlapping) string if there exists an identical substring. There are O(n2) total substrings and checking them against the remaining string will take O(n) time. So overall time complexity of above solution is O(n3).
Dynamic Programming : This problem can be solved in O(n2) time using Dynamic Programming. The basic idea is to find the longest repeating suffix for all prefixes in the string str.

Try solving now

2. XOR Query

Hard
45m average time
60% success
0/120
Asked in companies
ProtiumAmazonNokia

You are given a tree(root 0) with N vertex having N - 1 edges. You are also given an array ‘QUERY’ of size ‘Q’, where each query consists of an integer that denotes a node. You have to print the xor of all the values of nodes in the sub-tree of the given node.

Note:

Here XOR denotes the bitwise operator (^).
Problem approach

For each node we have to traverse the tree for every query find the xor of all the nodes of the sub-tree. So the complexity of the code will be O(N * Q).
Efficient approach: If we pre-compute the xor of all the nodes of the sub-tree by traversing the total tree once and first computing the xor of all the nodes of the sub-tree of the child node first and then using the value of the child node for computing the xor of all the nodes of the sub-tree of the parent node. In this way we can compute the xor in O(N) time and store them for queries. When a query is asked we will print the pre-computed value in O(1) time.

Try solving now

3. Fractional Knapsack

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

You have been given weights and values of ‘N’ items. You are also given a knapsack of size ‘W’.

Your task is to put the items in the knapsack such that the total value of items in the knapsack is maximum.

Note:
You are allowed to break the items.
Example:
If 'N = 4' and 'W = 10'. The weights and values of items are weights = [6, 1, 5, 3] and values = [3, 6, 1, 4]. 
Then the best way to fill the knapsack is to choose items with weight 6, 1 and  3. The total value of knapsack = 3 + 6 + 4 = 13.00   
Problem approach

Calculate the ratio(value/weight) for each item.
Sort all the items in decreasing order of the ratio.
Initialize res =0, curr_cap = given_cap.
Do the following for every item “i” in the sorted order:

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

What is recursion?

Choose another skill to practice
Similar interview experiences
SDE - 1
4 rounds | 8 problems
Interviewed by Tata1mg
1268 views
1 comments
0 upvotes
SDE - 1
4 rounds | 5 problems
Interviewed by Tata1mg
4933 views
0 comments
0 upvotes
SDE - 1
3 rounds | 5 problems
Interviewed by Tata1mg
1312 views
0 comments
0 upvotes
SDE - 1
4 rounds | 12 problems
Interviewed by Tata1mg
0 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
SDE - 1
5 rounds | 12 problems
Interviewed by Amazon
114579 views
24 comments
0 upvotes
company logo
SDE - 1
4 rounds | 5 problems
Interviewed by Microsoft
57825 views
5 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Amazon
34961 views
7 comments
0 upvotes