Code Room
CodingMediumcod-g413
Subject MathLevel Mid–Senior~20 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Given a non-negative number represented as an uppercase string num_str in base from_base, convert it to base to_base and return the result as an uppercase string. Both bases are between 2 and 16 inclusive; digits above 9 use letters A-F. The value fits in 64 bits. Zero must convert to the string '0'. For example ('FF', 16, 2) returns '11111111'.

Implement
convert_base(num_str: str, from_base: int, to_base: int) → str
Examples
in["FF",16,2]out"11111111"
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.