Problem Solving

Java Code to print Date and Time for a specific country

Write a Java program to print the current time in the different countries, In this java program example, we will see how to print the current time in the different countries. Sample Input Asia/Aden Sample Output current time is:09:03:19.232315600 Algorithm to print current time in the different countries Take the name of the country with …

Java Code to print Date and Time for a specific country Read More »

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 »