Talentd
FleetCode

504. Base 7

Easy55.3% acceptance4 companies

Given an integer num, return a string of its base 7 representation.

Example 1:

Input: num = 100
Output: "202"

Example 2:

Input: num = -7
Output: "-10"

Constraints:

  • -107 <= num <= 107

Topics

5:20
Still stuck?Read 3 approaches, or watch a walkthrough.
Open solution
Loading editor…
1class Solution:
2 def convertToBase7(self, num: int) -> str:
3
Starter codePython 3Spaces: 4
Examples
Input
100
Input
-7
Your code is saved on this device.Solution