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!
Create an Account
Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.
Create accountHow 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 Jan 2026
Contest runs January 1 - 31. Complete challenges to climb the leaderboard!
Points are calculated for challenges completed during the contest period.