πŸ“ Problem Details

πŸ’­What Were My Initial Thoughts?

- brute force approach and naive would be to check every combination of integers of size 2 - n to see if they have a trailing zero in their binary representation

- since we are looking for the binary representation of a value, theres most likley a pattern to when trailing zeros appear

πŸ€”What Did I Struggle With?

~

πŸ’‘ Explanation of Solution

- we only need to know if there are at least 2 even integers in the array
- performing the logical OR operation on 2 even integers is garunteed to return a value with a leading zero

βŒ› Complexity Analysis

Time Complexity: O(n)

Space Complexity: O(1)

πŸ’» Implementation of Solution

class Solution {
public:
    bool hasTrailingZeros(vector<int>& nums) {
        int count = 0;
 
        for(int num : nums) {
            if(num % 2 == 0) count++;
            if(count == 2) return true;
        }
 
        return false;
    }
};