Leetcode in Java && Oracle
419 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2021-11-16_02-57-00.png
52.3 KB
#N2032. Two Out of Three
problem link

#solution
class Solution {
public List<Integer> twoOutOfThree(int[] nums1, int[] nums2, int[] nums3) {
ArrayList<Integer> ans=new ArrayList<Integer>();
int[] helper1=new int[101];
int[] helper2=new int[101];
int[] helper3=new int[101];

for(int num:nums1)
helper1[num]=1;

for(int num:nums2)
helper2[num]=1;

for(int num:nums3)
helper3[num]=1;

for(int i=0; i<helper1.length; i++){
if(helper1[i]+helper2[i]+helper3[i]>1)
ans.add(i);
}

return ans;
}
}