Binary Gap

Given a positive integer n, find the longest gap between two consecutive 1 bits in its binary representation. The gap is measured as the number of bit positions between them. If fewer than two 1 bits exist, return 0.

Examples
Input: 22
Output: 2
Hints

Binary Gap

Given a positive integer n, find the longest gap between two consecutive 1 bits in its binary representation. The gap is measured as the number of bit positions between them. If fewer than two 1 bits exist, return 0.