Babylonian Numbers

Question

Solution

Idea

Time Complexity: O(n)O(n)

This question is not a give-away question, it needs some ability to break the problem into smaller pieces to solve.

  1. Iterate from the right to the left

  2. Once we encounter ',' add the corresponding number in base-60 to our sum

  3. Otherwise, update the corresponding number.

The implementaion logic can be seen from the code as follows:

Line 24 is to process the "first" number.

Code

https://github.com/mendax1234/Coding-Problems/blob/main/kattis/babylonian/babylonian.c

Last updated