Skip to content
View PeculiarE's full-sized avatar

Block or report PeculiarE

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Maximum 250 characters. Please don't include any personal information such as legal names or email addresses. Markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse

Pinned Loading

  1. Power of Four - LeetCode - Day 19 Power of Four - LeetCode - Day 19
    1
    [Question](https://leetcode.com/problems/power-of-four/description)
    2
    
                  
    3
    # Intuition
    4
    Building off [my bit-manipulation solution to the power of two problem](https://gist.github.com/PeculiarE/067b1c1be7fb614a16505a6a0f6e5c75), I knew that powers of 4 would only have one 1-bit. This is because a power of 4 is also a power of 2, and since the latter has only one 1-bit, then the same rule applies to the former.
    5
    
                  
  2. Hamming Distance - LeetCode - Day 20 Hamming Distance - LeetCode - Day 20
    1
    [Question](https://leetcode.com/problems/hamming-distance/description)
    2
    
                  
    3
    # Intuition
    4
    The bitwise XOR operator (^) always returns a 1 if two bits are different and 0 if they are the same.
    5
    
                  
  3. Number Complement - LeetCode - Day 21 Number Complement - LeetCode - Day 21
    1
    [Question](https://leetcode.com/problems/number-complement/description)
    2
    
                  
    3
    # Intuition
    4
    First thoughts:
    5
    - Because the probem states that leading zeros are not considered, simply flipping the bits using the NOT operator (~) won't work 
  4. Binary Number with Alternating Bits ... Binary Number with Alternating Bits - LeetCode - Day 22
    1
    [Question](https://leetcode.com/problems/binary-number-with-alternating-bits/description/?envType=problem-list-v2&envId=bit-manipulation)
    2
    
                  
    3
    # Intuition
    4
    - When you AND (&) a bit with 1, you'll get the same bit (0 & 1 = 0; 1 & 1 = 1).
    5
    - When you XOR (^) a bit with itself, you'll always get 0. But if you XOR a bit with its opposite, you'll always get 1
  5. Prime Number of Set Bits in Binary R... Prime Number of Set Bits in Binary Representation - LeetCode - Day 23
    1
    [Question](https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation/description)
    2
    
                  
    3
    # Intuition
    4
    Based on a previously solved problem ([Number of 1 Bits](https://gist.github.com/PeculiarE/6c4aa27d2805a7abab40e08894c069dc)), we already know how to count the number of 1-bits in a number. Now, we just have to do it for all the numbers in the provided range for this problem.
    5
    
                  
  6. Binary Gap - LeetCode - Day 24 Binary Gap - LeetCode - Day 24
    1
    [Question](https://leetcode.com/problems/binary-gap/description)
    2
    
                  
    3
    # Intuition
    4
    We have to go to through each bit in the number and track the positions of the 1-bits and the distances between them.
    5