# codechef-october-long-challenge-2019-msng-missing-number-discuss-approach-code Codechef October Long Challenge – 2019 – MSNG – Missing Number – Approach Discussion and Code

This video very clearly explains the problem statement , logic to solve the problem and also the correct solution.

What is the problem statement?

We are given N pairs of (Base, Number) where the base can be in the range [2,36], and if base is missing than base =-1. The number is represented as a string with a maximum length of 40. The task is to find the smallest possible number X in decimal representation (in base 10) and fill in all missing bases in such a way that the second numbers in all pairs written on the walls, when converted from their bases to base 10 are equal to X.

How to solve this problem?

In this question, the brute force approach will work.

1) If the base of a pair is not equal to -1, then simply convert the number with the given base into base 10 and store it in a hashmap.
2) If the base of a pair is equal to -1, then from the minimum possible base to 36 find all the possible numbers after conversion and store them in hashmap and a set(Explained in the video)
3) Finally, get the keys with value==n and from those keys print the minimum keys. If the result is more than 10^12 or negative print -1.

Code Live with Top coders. Learn coding with experts : http://bit.ly/2MGRnZK

Source

Article Rating
Subscribe
Notify of Inline Feedbacks