LTI - Larsen & Toubro Infotech interview experience Real time questions & tips from candidates to crack your interview

Senior Software Engineer

LTI - Larsen & Toubro Infotech
upvote
share-icon
1 rounds | 2 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 1 month
Topics: Data Structures, Pointers, OOPS, System Design, Algorithms, Dynamic Programming, Java, Spring
Tip
Tip

Tip 1 : Practice writing clean code.
Tip 2 : DSA basics have to be clear
Tip 3 : Do brush up on your Java and spring basics.

Application process
Where: Linkedin
Eligibility: 3 years of experience.
Resume Tip
Resume tip

Tip 1 : Highlight your most important skills.
Tip 2 : Describe properly your role in your current company.

Interview rounds

01
Round
Hard
Video Call
Duration60 minutes
Interview date24 Jul 2021
Coding problem2

The interview was conducted over MS Teams on a Saturday afternoon.

1. Ninja And Cities

Hard
50m average time
50% success
0/120
Asked in companies
AdobeLTI - Larsen & Toubro InfotechAdrosonic

Ninja decided to find the distance between the neighbouring cities and then store them for future use. He took data from the map and developed an input format. He is given an integer ‘N’ denoting the number of cities and then he has an array of size ‘N - 1’ that stores a pair of numbers at each index. Let the pair be ‘I1’ and ‘I2’, which will denote a bidirectional edge between the two cities ‘I1’ and ‘I2’.

A subtree is a subset of cities, where each city can be reached from every other city of the subset. The path between each pair passes only though the cities present in the subset. Two subtrees are taken differently if there are one or more cities in one subtree not present in the other.

Now, you need to create an array of ‘N' - 1 elements where the ‘ith’ element is the number of subtrees in which the maximum distance between any two cities is equal to ‘i’.

Note:
1. Note that there exists a unique path between each pair of cites. Also, the final array that you need to create should be 1-indexed, meaning cities with a maximum distance = 1 should be stored on the normal 0th index.

2. Also, note that the distance between two is the number of cities you cross in between.
Example:
Given 'N' = 7, and Array = {[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]}

So the tree of cities formed in this case would look like:


In the above problem, the subtrees with subsets {[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]}, have a maximum distance of 1, so put 6 on index 1.

Similarly the subtrees with subsets {[1, 2, 4], [1, 2, 5], [2, 1, 3], [4, 2, 5], [1, 3, 6], [1, 3, 7], [6, 3, 7], [1, 2, 4, 5], [1, 3, 6, 7]} have a maximum distance of 2, so put 9 on index 2.

Now, the subtrees with subsets {[4, 2, 1, 3], [2, 1, 3, 7], [5, 2, 1, 3], [2, 1, 3, 6], [4, 5, 2, 1, 3], [2, 1, 3, 6, 7]} have a maximum distance of 3, so put 6 on index 3.

Now, the subtrees with subsets {[4, 2, 1, 3, 7], [4, 2, 1, 3, 6], [5, 2, 1, 3, 7], [5, 2, 1, 3, 6], [5, 2, 1, 3, 6, 7], [4, 2, 1, 3, 6, 7], [4, 2, 5, 1, 3, 6], [4, 2, 5, 1, 3, 7], [4, 2, 5, 1, 3, 6, 7]} have a maximum distance of 4, so put 12 on index 4.

No subtree has two nodes where the maximum distance between them is 5 and 6 so print 0 on both these indexes.

 Final resultant array = [6, 9, 6, 9, 0, 0]
Problem approach

I used a Hashmap with integer type as key and string type as value. Sorted the hashmap using map.keySet.

Try solving now

2. Rat In A Maze

Easy
15m average time
85% success
0/40
Asked in companies
Samsung R&D InstituteDeutsche BankMakeMyTrip

You are given a starting position for a rat which is stuck in a maze at an initial point (0, 0) (the maze can be thought of as a 2-dimensional plane). The maze would be given in the form of a square matrix of order 'N' * 'N' where the cells with value 0 represent the maze’s blocked locations while value 1 is the open/available path that the rat can take to reach its destination. The rat's destination is at ('N' - 1, 'N' - 1). Your task is to find all the possible paths that the rat can take to reach from source to destination in the maze. The possible directions that it can take to move in the maze are 'U'(up) i.e. (x, y - 1) , 'D'(down) i.e. (x, y + 1) , 'L' (left) i.e. (x - 1, y), 'R' (right) i.e. (x + 1, y).

Note:
Here, sorted paths mean that the expected output should be in alphabetical order.
For Example:
Given a square matrix of size 4*4 (i.e. here 'N' = 4):
1 0 0 0
1 1 0 0
1 1 0 0
0 1 1 1 
Expected Output:
DDRDRR DRDDRR 
i.e. Path-1: DDRDRR and Path-2: DRDDRR

The rat can reach the destination at (3, 3) from (0, 0) by two paths, i.e. DRDDRR and DDRDRR when printed in sorted order, we get DDRDRR DRDDRR.
Problem approach

Used dynamic programming

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

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

Choose another skill to practice
Similar interview experiences
Software Engineer
2 rounds | 7 problems
Interviewed by LTI - Larsen & Toubro Infotech
1018 views
0 comments
0 upvotes
Senior Software Engineer
3 rounds | 5 problems
Interviewed by LTI - Larsen & Toubro Infotech
1368 views
0 comments
0 upvotes
SDE - 1
4 rounds | 5 problems
Interviewed by LTI - Larsen & Toubro Infotech
0 views
0 comments
0 upvotes
Software Engineer
4 rounds | 5 problems
Interviewed by LTI - Larsen & Toubro Infotech
689 views
0 comments
0 upvotes
Companies with similar interview experiences
company logo
Senior Software Engineer
1 rounds | 6 problems
Interviewed by Arcesium
3920 views
0 comments
0 upvotes
company logo
Senior Software Engineer
3 rounds | 3 problems
Interviewed by Ernst & Young (EY)
5173 views
0 comments
0 upvotes
company logo
Senior Software Engineer
3 rounds | 3 problems
Interviewed by HCL Technologies
3156 views
3 comments
0 upvotes