The naïve approach to solve the problem would be to first convert the given number into its binary representation and then change every 1’s to 0 and 0’s to 1. After changing all 0’s and 1’s convert the binary representation to number.
Input : n = 5
Output : 2
Input : n = 255
Output : 0
Input : n = 26
Output : 5
Find One’s Complement of an Integer : https://www.geeksforgeeks.org/find-ones-complement-integer/