PROBLEM DESCRIPTION
Given a number N >= 0, find its representation in binary.
Example: if N = 6, binary form = 110
SOLUTION
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class Solution {
public String findDigitsInBinary(int A) {
if(A == 0) return "0";
StringBuffer sb = new StringBuffer();
while(A != 0){
sb.insert(0, A%2);
A = A/2;
}
return sb.toString();
}
}