Problem Solving

Merge collection of intervals in Java

Given a collection of intervals, merge all overlapping intervals. For Example: Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18]. The key to solving this problem is defining a Comparator first to sort the ArrayList of Intervals. And then merge some intervals. The take-away message from this problem is utilizing the advantage of sorted list/array class Interval { int start; …

Merge collection of intervals in Java Read More »

Find the shortest chain in Java (Find Ladder Length)

Given two words (start and end), and a dictionary, find the length of the shortest transformation sequence from start to end, such that: Only one letter can be changed at a time Each intermediate word must exist in the dictionary For example, Given: start = “hit” end = “cog” dict = [“hot”,”dot”,”dog”,”lot”,”log”] As one shortest …

Find the shortest chain in Java (Find Ladder Length) Read More »