number = 0
counter = 1
n.to_s(2).rjust(32, "0").each_char do |c|
number += c.to_i*counter
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.