Convert a non-negative integer to its binary string representation without using built-in conversion methods. Binary representation uses only 0s and 1s, where each position represents a power of 2.
In Salesforce development, understanding binary operations is useful for permission sets, bitmasking operations, or custom encoding scenarios in integrations.
Examples:
Input: num = 0
Output: "0"
Explanation: Zero in binary is represented as "0"
Input: num = 5
Output: "101"
Explanation: 5 in decimal is 101 in binary (4 + 0 + 1 = 5)
Input: num = 255
Output: "11111111"
Explanation: 255 in decimal is 11111111 in binary (128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255)
Apex Code Editor
Welcome to Lightning Challenge!
How It Works
- • Write your solution in the code editor
- • Connect your Salesforce org to test
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
🏆 #CodeEveryDay July 2026
Contest runs July 1 - 31. Complete challenges to climb the leaderboard!
Only the 31 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.