Decimal to Base K conversion
Basic Accuracy: 0.0% Submissions: 17 Points: 1

Given 2 integers N and K. Convert N(given in Decimal) to base K.

 

Example 1:

Input:
N = 10, K = 2
Output:
1010
Explanation:
(10)10 = (1010)2

Example 2:

Input:
N = 4, K = 8
Output:
4
Explanation:
(4)10 = (4)8

 

Your Task:
You don't need to read input or print anything. Your task is to complete the function changeBase() which takes Integers N and K as input and returns an integer as the answer.

 

Expected Time Complexity: O(logKN)
Expected Auxiliary Space: O(logKN)

 

Constraints:
1 <= N <= 105
2 <= K <= 10

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.