Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Version Checker

Limits: 1s, 256 MB

Java Development Kit (JDK) installer for Mac OS X has a bug:

Can you spot it? Notice how Java is checking the operating system version number. Logic dictates that 10.10.5 is obviously a newer version than 10.7.3. So something is incorrect in the way the installer trying to compare the version numbers. Can you come up with a correct algorithm? Do you have what it takes to get this right?


There will be only one line with two version strings. Each version number can have no dots or at most two (.) dots. And there will be at most two consecutive digits (0 - 9) in the given version number.


You need to print out the latest version number comparing the given two versions. If the both version numbers are the same print the string that is longest in terms of string length.


10.11.12 10.99.99
11.1 1.11

In the second sample case 1.11 can be considered as 01.11.00 and 11.1 can be considered as 11.01.00.

  • faiyaz26's Avatar


    Faiyaz refers to himself as a lazy software engineer. He likes coffee, sleep and solving problems. He qualified to ACM-ICPC World Finals 2016 from North South University and secured top ranks in numerous national contests.