Algorithm · Tesla · Medium
You are given an array arr of positive integers. You may choose any subset of its elements; the selected elements do not have to be adjacent in the array. Find the largest possible subset size such that the bitwise AND of all selected elements is greater than 0. Return the size of that largest valid subset. Constraints: 1 ≤ arr.length ≤ 10 5 1 ≤ arr[i] ≤ 10 9 Example 1: Input: arr = [7, 13, 8, 2, 3] Output: 3 Explanation: One valid size-3 subset is {7, 2, 3}: 7 & 2 & 3 = 2,…
Checking your access…