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

Java Developer

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

Interview preparation journey

expand-icon
Preparation
Duration: 5 months
Topics: Java, Spring, Hibernate, DSA, OOPS, System Design
Tip
Tip

Tip 1 : If you are thorough with core java concepts and any JAVA framework, be it SPRING, HIBERNATE. then you are good to go.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 3 : Do at-least 2 good projects and you must know every bit of them.

Application process
Where: Other
Eligibility: Above 7 CGPA
Resume Tip
Resume tip

Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.

Interview rounds

01
Round
Easy
Video Call
Duration60 minutes
Interview date19 Apr 2021
Coding problem3

A coding problem was given. Other questions were based on Java.

1. Longest Harmonious Subsequence

Hard
15m average time
85% success
0/120
Asked in companies
AppleeBayLTI - Larsen & Toubro Infotech

You are given an array ‘ARR’ of 'N' integers. Your task is to find the longest harmonious subsequence of this array.

A sequence is Harmonious if the difference between the maximum and the minimum of all the elements is exactly 1.

For example
[3, 4, 3, 3, 3, 3, 4] is a harmonic array as the maximum of all the elements is 4 and minimum of all the elements is 3. So, the difference between the maximum and the minimum = 4 - 3 = 1.
Problem approach

The idea is to generate all the possible subsequences using the bit masking technique. For each subsequence, check if it is a Harmonious subsequence or not. Take the maximum length of all the possible subsequences.

 

The steps are as follows:

  • Initialize 'ANSWER' to 0, which denotes the longest length of the Harmonic subsequence.
  • Iterate from ‘i’ = 0 to ‘2^N - 1’, where ‘N’ is the length of the given Array, ‘ARR’.
    • Initialize three integers ‘MIN_VALUE’, ‘MAX_VALUE’, and ‘COUNT_LENGTH’ with INT_MAX, INT_MIN, and 0 respectively which stores the minimum, maximum values of the current subsequence and length of the current subsequence respectively.
    • Iterate from ‘j’ = 0 to ‘N-1’:
      • If a jth bit of i is set and ‘MIN_VALUE’ is less than ARR[j], then update ‘MIN_VALUE’ to ARR[j].
      • If a jth bit of i is set and ‘MAX_VALUE’ is greater than ARR[j], then update ‘MAX_VALUE’ to ARR[j].
      • Increment the count as we are including the current element in the subsequence.
    • If the difference between the ‘MAX_VALUE’ and ‘MIN_VALUE’ is 1. It means it is a valid subsequence. Update 'ANSWER' to a maximum of 'ANSWER' and ‘COUNT_LENGTH’. Also, take care of the integer overflow.
  • Return 'ANSWER’ as the final answer.


 

Try solving now

2. Java Question

What are collections in Java?

Problem approach

The Collection in Java is a framework that provides an architecture to store and manipulate the group of objects.
Java Collections can achieve all the operations that you perform on a data such as searching, sorting, insertion, manipulation, and deletion.
Java Collection means a single unit of objects. Java Collection framework provides many interfaces (Set, List, Queue, Deque) and classes (ArrayList
, Vector, LinkedList
, PriorityQueue
, HashSet, LinkedHashSet, TreeSet).

3. Java Question

Difference between ArrayList and HashMap in Java

Problem approach

1. ArrayList implements the List interface. HashMap implements the Map interface.
2. ArrayList implements the List interface. HashMap implements the Map interface.
3. ArrayList stores element's value and maintains the indexes for each element. HashMap stores elements key & value pair. For each value, there must be a key associated with HashMap.
4. ArrayList stores only a single object. HashMap stores elements in Key and value pairs.
5. We get the element by specifying the index of it in ArrayList. The elements are being fetched by the corresponding Key in HashMap.
6. The ArrayList maintains the order of the objects they are inserted. HashMap does not provide a guarantee of the order in which they are inserted.

02
Round
Easy
Video Call
Duration60 minutes
Interview date19 Apr 2021
Coding problem3

Technical Interview round with questions based on Java and Spring.

1. Java Question

What is a REST API?

Problem approach

A REST API (also known as RESTful API) is an application programming interface (API or web API) that conforms to the constraints of REST architectural style and allows for interaction with RESTful web services. REST stands for representational state transfer and was created by computer scientist Roy Fielding.

2. Java Question

Difference between static and final

Problem approach

The main difference between static and final is that the static is used to define the class member that can be used independently of any object of the class. In contrast, final is used to declare a constant variable or a method that cannot be overridden or a class that cannot be inherited.

3. Java Question

How to create Immutable class?

Problem approach

There are many immutable classes like String, Boolean, Byte, Short, Integer, Long, Float, Double etc. In short, all the wrapper classes and String class is immutable. To create an immutable class, create a final class that have final data members.

Example :

public final class Employee 

final String pancardNumber; 
public Employee(String pancardNumber) 

this.pancardNumber=pancardNumber; 

public String getPancardNumber(){ 
return pancardNumber; 


public class ImmutableDemo 

public static void main(String ar[]) 

Employee e = new Employee("ABC123"); 
String s1 = e.getPancardNumber(); 
System.out.println("Pancard Number: " + s1); 

}

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
SDE - 1
4 rounds | 5 problems
Interviewed by LTI - Larsen & Toubro Infotech
0 views
0 comments
0 upvotes
Senior Software Engineer
1 rounds | 2 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
Java Developer
3 rounds | 20 problems
Interviewed by Ernst & Young (EY)
9400 views
2 comments
0 upvotes
company logo
Java Developer
2 rounds | 2 problems
Interviewed by HCL Technologies
7972 views
0 comments
0 upvotes