Number of 1 Bits (LeetCode 191)The problem Given a non-negative integer (treated as an unsigned 32-bit value…