From f8ac345964bb06e838bd4e0ffb47df7386d310de Mon Sep 17 00:00:00 2001 From: chayan das <110921638+Chayandas07@users.noreply.github.com> Date: Thu, 7 Nov 2024 11:49:57 +0530 Subject: [PATCH] Create 2275. Largest Combination With Bitwise AND Greater Than Zero --- ...bination With Bitwise AND Greater Than Zero | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 2275. Largest Combination With Bitwise AND Greater Than Zero diff --git a/2275. Largest Combination With Bitwise AND Greater Than Zero b/2275. Largest Combination With Bitwise AND Greater Than Zero new file mode 100644 index 0000000..711bdd8 --- /dev/null +++ b/2275. Largest Combination With Bitwise AND Greater Than Zero @@ -0,0 +1,18 @@ +class Solution { +public: + int largestCombination(vector& c) { + vector v(32,0); + for(auto it : c){ + for(int i = 31; i>=0; i--){ + int k = it >> i; + if(k & 1) v[i]++; + } + } + int ans = 0; + for(int i = 0; i<32; i++){ + ans = max(ans,v[i]); + } + + return ans; + } +};