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 October 2026 (Oct 4–15)Sponsored by FLXBL
Contest runs October 4 - 15. Complete challenges to climb the leaderboard!
Prizes 1 & 2: Salesforce certification exam voucher — won by random drawing, where every point is a ticket. see all prizes
Only the 12 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.