We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2f2e3b5 commit cd76a47Copy full SHA for cd76a47
scripts/algorithms/T/Two Out of Three/Two Out of Three.java
@@ -1,13 +1,14 @@
1
+// Runtime: 2 ms (Top 97.56%) | Memory: 46.7 MB (Top 58.76%)
2
class Solution {
3
public List<Integer> twoOutOfThree(int[] nums1, int[] nums2, int[] nums3) {
4
int[] bits = new int[101];
- for (int n : nums1) bits[n] |= 0b110;
5
- for (int n : nums2) bits[n] |= 0b101;
6
- for (int n : nums3) bits[n] |= 0b011;
+ for (int n : nums1) bits[n] |= 0b110;
+ for (int n : nums2) bits[n] |= 0b101;
7
+ for (int n : nums3) bits[n] |= 0b011;
8
List<Integer> result = new ArrayList();
9
for (int i = bits.length - 1; i > 0; i--)
10
if (bits[i] == 0b111)
11
result.add(i);
12
return result;
13
}
-}
14
+}
0 commit comments