DataRepo's picture
Duplicate from FPEvalDataset/LeetCodeProblem
f7c0146 verified
{
"id": 3246,
"name": "check_if_bitwise_or_has_trailing_zeros",
"difficulty": "Easy",
"link": "https://leetcode.com/problems/check-if-bitwise-or-has-trailing-zeros/",
"date": "2023-12-24 00:00:00",
"task_description": "You are given an array of **positive** integers `nums`. You have to check if it is possible to select **two or more** elements in the array such that the bitwise `OR` of the selected elements has **at least **one trailing zero in its binary representation. For example, the binary representation of `5`, which is `\"101\"`, does not have any trailing zeros, whereas the binary representation of `4`, which is `\"100\"`, has two trailing zeros. Return `true` _if it is possible to select two or more elements whose bitwise_ `OR` _has trailing zeros, return_ `false` _otherwise_. **Example 1:** ``` **Input:** nums = [1,2,3,4,5] **Output:** true **Explanation:** If we select the elements 2 and 4, their bitwise OR is 6, which has the binary representation \"110\" with one trailing zero. ``` **Example 2:** ``` **Input:** nums = [2,4,8,16] **Output:** true **Explanation: **If we select the elements 2 and 4, their bitwise OR is 6, which has the binary representation \"110\" with one trailing zero. Other possible ways to select elements to have trailing zeroes in the binary representation of their bitwise OR are: (2, 8), (2, 16), (4, 8), (4, 16), (8, 16), (2, 4, 8), (2, 4, 16), (2, 8, 16), (4, 8, 16), and (2, 4, 8, 16). ``` **Example 3:** ``` **Input:** nums = [1,3,5,7,9] **Output:** false **Explanation:** There is no possible way to select two or more elements to have trailing zeros in the binary representation of their bitwise OR. ``` **Constraints:** `2 <= nums.length <= 100` `1 <= nums[i] <= 100`",
"public_test_cases": [
{
"label": "Example 1",
"input": "nums = [1,2,3,4,5]",
"output": "true "
},
{
"label": "Example 2",
"input": "nums = [2,4,8,16]",
"output": "true "
},
{
"label": "Example 3",
"input": "nums = [1,3,5,7,9]",
"output": "false "
}
],
"private_test_cases": [
{
"input": [
38,
96,
54,
93,
34,
65,
95,
25,
63,
49,
32,
96,
5,
46,
95,
16,
53,
25,
1,
84,
18,
3,
91,
20,
63,
11,
71,
63,
63,
2,
98,
68
],
"output": true
},
{
"input": [
17,
64,
92,
91,
94,
66,
87,
91,
18,
44,
65,
37,
41,
16,
38,
74,
91,
37,
38,
36,
9,
4,
7,
75,
3
],
"output": true
},
{
"input": [
73,
56,
23,
72,
18,
92,
82,
54,
87,
3,
1,
77,
70,
15,
24,
72,
47,
27,
82,
11,
87,
21,
47,
75,
53,
3,
21,
4,
84,
64,
4,
36,
52,
40,
80,
86,
25,
74,
1,
2,
90,
35,
5,
82,
45,
59,
78,
1,
56,
16,
63,
69,
86,
65,
62,
8,
54,
92,
35
],
"output": true
},
{
"input": [
26,
41,
28,
25,
23,
11,
71,
31,
38,
23,
58,
87,
51,
80,
73,
53,
69,
94,
65,
73,
92,
96,
82,
89,
33,
51,
68,
16,
73,
92,
7,
13,
25,
35,
42,
34,
3,
45,
84,
73,
47,
60,
83,
16,
94,
85,
90,
19,
58,
32,
29,
2,
19,
90,
80,
60,
21,
64,
21,
50,
27,
8,
71,
59,
19,
55,
13,
31,
92,
36,
90,
44,
29,
88
],
"output": true
},
{
"input": [
3,
80,
72,
87,
40,
47,
92,
43,
47,
27,
51,
14,
23
],
"output": true
}
],
"haskell_template": "hasTrailingZeros :: [Int] -> Bool\nhasTrailingZeros nums ",
"ocaml_template": "let hasTrailingZeros (nums: int list) : bool = ",
"scala_template": "def hasTrailingZeros(nums: List[Int]): Boolean = { \n \n}",
"java_template": "class Solution {\n public boolean hasTrailingZeros(int[] nums) {\n \n }\n}",
"python_template": "class Solution(object):\n def hasTrailingZeros(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: bool\n \"\"\"\n "
}