Parse an Integer in Any Base

Asked at Microsoft· Onsite

Reported by the problem's creator, not verified

Import another question

You implement one function, parse_base_integer(text, base). Each test is a single call. It returns the decimal value of text read in base as a string, or the word INVALID or OVERFLOW when the text or the value is not acceptable.

Examples

  1. Example 1

    Input: text = ff, base = 16

    Output: 255

    Explanation: f is 15, so ff is 15 * 16 + 15 = 255.

Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.
Import a question

Code

Loading editor…

Ln 1, Col 1

Start an attempt to use Coach.