Skip to content

Michinggun/vt-career-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vt-career-java

Veritrans Java Developer Career Task

A complement of a number is defined as inversion (if the bit value = 0, change it to 1 and vice-versa) of all bits of the number starting from the leftmost bit that is set to 1.

For example, if N = 5, N is 101 in binary. The complement of N is 010, which is 2 in decimal. Similarly if N = 50, then complement of N is 13 Complete the function getIntegerComplement(). This function takes N as it's parameter. The function should return the complement of N. Constraints : 0 ≤ N ≤ 100000.

Sample Test Cases:

Input #00: 50

Output #00: 13

Explanation: 50 in decimal form equals: 110010. Inverting the bit sequence: 001101. This is 13 in decimal Input #01: 100

Output #01: 27

Explanation: The bit sequence for 100 equals 1100100. Inverting the sequence we get 0011011 which is 27 in decimal.

About

Veritrans Java Developer Career Task

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages