![]() |
VOOZH | about |
Given a number of digits 'N' and base 'B', the task is to count all the 'N' digit numbers without leading zeros that are in base 'B'
Examples:
Input: N = 2, B = 2 Output: 2 All possible numbers without leading zeros are 10 and 11. Input: N = 5, B = 8 Output: 28672
Approach:
Below is the implementation of the above approach:
3072
Time Complexity: O(logn), since pow function takes logn time to find the power of a number to base n.Auxiliary Space: O(1), since no extra space has been taken.