Talentd
FleetCode

1256. Encode Number

Medium70.0% acceptance1 companyPremium elsewhere, free here

Given a non-negative integer num, Return its encoding string.

The encoding is done by converting the integer to a string using a secret function that you should deduce from the following table:

Example 1:


Input: num = 23

Output: "1000"

Example 2:


Input: num = 107

Output: "101100"

Constraints:

  • 0 <= num <= 10^9

Asked at 1 company

Hints open one at a time

Hint 1
Try to find the number of binary digits returned by the function.
Hint 2
The pattern is to start counting from zero after determining the number of binary digits.
13:23
Still stuck?Read the written solution, or watch a walkthrough.
Open solution

Similar problems

Convert to Base -2Medium
Loading editor…
1class Solution:
2 def solve(self):
3 pass
4
Starter codePython 3Spaces: 4
Examples
Input
23
Input
107
Your code is saved on this device.Solution