L&T 2024 Papers
Previous year papers with coding questions
Practice L&T placement paper coding questions with detailed solutions. Access L&T OA coding problems in C++, Java, Python.
This page contains L&T coding questions from L&T OA placement papers with detailed solutions.
L&T OA Coding Section:
Solution (Java):
public List<String> scheduleProjects(Map<String, List<String>> dependencies) { Map<String, Integer> inDegree = new HashMap<>(); Map<String, List<String>> graph = new HashMap<>();
// Build graph and calculate in-degrees for (String project : dependencies.keySet()) { inDegree.putIfAbsent(project, 0); for (String dep : dependencies.get(project)) { graph.putIfAbsent(dep, new ArrayList<>()).add(project); inDegree.put(project, inDegree.getOrDefault(project, 0) + 1); } }
// Topological sort Queue<String> queue = new LinkedList<>(); for (String project : inDegree.keySet()) { if (inDegree.get(project) == 0) queue.offer(project); }
List<String> result = new ArrayList<>(); while (!queue.isEmpty()) { String project = queue.poll(); result.add(project); for (String next : graph.getOrDefault(project, new ArrayList<>())) { inDegree.put(next, inDegree.get(next) - 1); if (inDegree.get(next) == 0) queue.offer(next); } }
return result;}Time Complexity: O(V + E)
L&T 2024 Papers
Previous year papers with coding questions
L&T Main Page
Complete L&T placement guide
Practice L&T coding questions regularly!