Answer: LOCKHEED MARTIN Hiring Challenge | Interview Online Assessment Question

Answer · Posted Jun 2026

Approach Sort the pairs based on their ending values. Always choose the pair that ends first. Greedily select the next pair whose start is greater than the previous end. Strategy      Sort pairs by second element. Initialize the current end to negative infinity. Traverse the sorted pairs. If the current pair can be chained, include it. Return the total count. Java Code import java.util.Arrays; class Solution { public int findLongestChain(int[][] pairs) { Arrays.sort(pairs, (a, b) -> a[1] - b[1]); ...

The full answer & interview discussion are available to premium members.

Log in Create a free account