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

SDE - 1

Tata1mg
upvote
share-icon
3 rounds | 6 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 : works on your basics properly
Tip 2 : Practice more and more programming questions
Tip 3 : Depth knowledge of your project is a must.

Application process
Where: Campus
Eligibility: 7 CGPA+ No active Backlog
Resume Tip
Resume tip

Tip 1 : add more and more projects to your resume
Tip 2 : only mention those skills you have a firm grip.

Interview rounds

01
Round
Medium
Online Coding Interview
Duration90 minutes
Interview date9 Dec 2021
Coding problem2

1. Box Stacking

Hard
25m average time
65% success
0/120
Asked in companies
DirectiMorgan StanleyJio Platforms Limited

You are given a set of ‘n’ types of rectangular 3-D boxes. The height, width, and length of each type of box are given by arrays, ‘height’, ‘width’, and ‘length’ respectively, each consisting of ‘n’ positive integers. The height, width, length of the i^th type box is given by ‘height[i]’, ‘width[i]’ and ‘length[i]’ respectively.

You need to create a stack of boxes that is as tall as possible using the given set of boxes.

Below are a few allowances:

You can only stack a box on top of another box if the dimensions of the 2-D base of the lower box ( both length and width ) are strictly larger than those of the 2-D base of the higher box. 

You can rotate a box so that any side functions as its base. It is also allowed to use multiple instances of the same type of box. This means, a single type of box when rotated, will generate multiple boxes with different dimensions, which may also be included in stack building.

Return the height of the highest possible stack so formed.

alt text

Note:
The height, Width, Length of the type of box will interchange after rotation.

No two boxes will have all three dimensions the same.

Don’t print anything, just return the height of the highest possible stack that can be formed.
Problem approach

1)Generate all 3 rotations of all boxes. The size of rotation array becomes 3 times the size of the original array. For simplicity, we consider width as always smaller than or equal to depth. 
2) Sort the above generated 3n boxes in decreasing order of base area.
3) After sorting the boxes, the problem is same as LIS with following optimal substructure property. 
MSH(i) = Maximum possible Stack Height with box i at top of stack 
MSH(i) = { Max ( MSH(j) ) + height(i) } where j < i and width(j) > width(i) and depth(j) > depth(i). 
If there is no such j then MSH(i) = height(i)
4) To get overall maximum height, we return max(MSH(i)) where 0 < i < n

Try solving now

2. Shortest Common Supersequence

Hard
25m average time
0/120
Asked in companies
Dream11Thought WorksSamsung

Given two strings, ‘A’ and ‘B’. Return the shortest supersequence string ‘S’, containing both ‘A’ and ‘B’ as its subsequences. If there are multiple answers, return any of them.

Note: A string 's' is a subsequence of string 't' if deleting some number of characters from 't' (possibly 0) results in the string 's'.

For example:
Suppose ‘A’ = “brute”, and ‘B’ = “groot”

The shortest supersequence will be “bgruoote”. As shown below, it contains both ‘A’ and ‘B’ as subsequences.

A   A A     A A
b g r u o o t e
  B B   B B B  

It can be proved that the length of supersequence for this input cannot be less than 8. So the output will be bgruoote.
Problem approach

1) Find Longest Common Subsequence (lcs) of two given strings. For example, lcs of “geek” and “eke” is “ek”. 
2) Insert non-lcs characters (in their original order in strings) to the lcs found above, and return the result. So “ek” becomes “geeke” which is shortest common supersequence.
Let us consider another example, str1 = “AGGTAB” and str2 = “GXTXAYB”. LCS of str1 and str2 is “GTAB”. Once we find LCS, we insert characters of both strings in order and we get “AGXGTXAYB”
How does this work? 
We need to find a string that has both strings as subsequences and is shortest such string. If both strings have all characters different, then result is sum of lengths of two given strings. If there are common characters, then we don’t want them multiple times as the task is to minimize length. Therefore, we first find the longest common subsequence, take one occurrence of this subsequence and add extra characters. 

Length of the shortest supersequence 
= (Sum of lengths of given two strings) 
- (Length of LCS of two given strings)

Try solving now
02
Round
Medium
Video Call
Duration70 minutes
Interview date11 Dec 2021
Coding problem2

1. Ways To Make Coin Change

Moderate
20m average time
80% success
0/80
Asked in companies
AmazonCIS - Cyber InfrastructureLinkedIn

You are given an infinite supply of coins of each of denominations D = {D0, D1, D2, D3, ...... Dn-1}. You need to figure out the total number of ways W, in which you can make a change for value V using coins of denominations from D. Print 0, if a change isn't possible.

Problem approach

To count the total number of solutions, we can divide all set solutions into two sets. 
1) Solutions that do not contain mth coin (or Sm). 
2) Solutions that contain at least one Sm. 
Let count(S[], m, n) be the function to count the number of solutions, then it can be written as sum of count(S[], m-1, n) and count(S[], m, n-Sm).
Therefore, the problem has optimal substructure property as the problem can be solved using solutions to subproblems.

Try solving now

2. Partition Equal Subset Sum

Moderate
25m average time
65% success
0/80
Asked in companies
OlaOracleSAP Labs

You are given an array 'ARR' of 'N' positive integers. Your task is to find if we can partition the given array into two subsets such that the sum of elements in both subsets is equal.

For example, let’s say the given array is [2, 3, 3, 3, 4, 5], then the array can be partitioned as [2, 3, 5], and [3, 3, 4] with equal sum 10.

Follow Up:

Can you solve this using not more than O(S) extra space, where S is the sum of all elements of the given array?
Problem approach

Following are the two main steps to solve this problem: 
1) Calculate sum of the array. If sum is odd, there can not be two subsets with equal sum, so return false. 
2) If sum of array elements is even, calculate sum/2 and find a subset of array with sum equal to sum/2.

Try solving now
03
Round
Medium
Face to Face
Duration90 minutes
Interview date15 Dec 2021
Coding problem2

1. Partition a set into two subsets such that the difference of subset sums is minimum.

Hard
10m average time
85% success
0/120
Asked in companies
Goldman SachsSterlite Technologies LimitedIntuit

You are given an array 'arr' containing 'n' non-negative integers.


Your task is to partition this array into two subsets such that the absolute difference between subset sums is minimum.


You just need to find the minimum absolute difference considering any valid division of the array elements.


Note:

1. Each array element should belong to exactly one of the subsets.

2. Subsets need not always be contiguous.
For example, for the array : [1, 2, 3], some of the possible divisions are 
   a) {1,2} and {3}
   b) {1,3} and {2}.

3. Subset-sum is the sum of all the elements in that subset. 
Example:
Input: 'n' = 5, 'arr' = [3, 1, 5, 2, 8].

Ouput: 1

Explanation: We can partition the given array into {3, 1, 5} and {2, 8}. 
This will give us the minimum possible absolute difference i.e. (10 - 9 = 1).
Try solving now

2. Longest Route

Moderate
15m average time
85% success
0/80
Asked in companies
HSBCFacebookTata1mg

You are given a 2-D binary matrix "Mat" of dimensions N x M consisting only of 0s and 1s. The cell consisting of 0 means that the cell is blocked and it cannot be visited whereas a cell with 1 as a value means it can be visited.

You are given a source cell and a destination cell. You need to find the length of the longest possible path from source to destination, given you can only move in 4 possible directions north(i.e from (i,j) to (i-1,j)), south(i.e from (i,j) to (i+1,j)), east(i.e from (i,j) to (i,j-1)), and west(i.e from (i,j) to (i,j+1)), and without visiting a cell twice.

Note:
1. If the move isn’t possible you remain in that cell only.
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
1267 views
1 comments
0 upvotes
SDE - 1
3 rounds | 5 problems
Interviewed by Tata1mg
1312 views
0 comments
0 upvotes
SDE - 1
1 rounds | 3 problems
Interviewed by Tata1mg
1636 views
1 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
57824 views
5 comments
0 upvotes
company logo
SDE - 1
3 rounds | 7 problems
Interviewed by Amazon
34961 views
7 comments
0 upvotes