Skip to content

Commit

Permalink
Time: 4 ms (72.92%), Space: 45.5 MB (76.3%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit-S-Sahu committed Jan 14, 2025
1 parent d483e7f commit 361f9c5
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution {
public int[] findThePrefixCommonArray(int[] A, int[] B) {
HashSet<Integer> set = new HashSet<>();
int ans[] = new int[A.length];
for (int i = 0; i < A.length; i++) {
set.add(A[i]);
set.add(B[i]);
ans[i] = 2 * (i + 1) - set.size();
}

return ans;
}
}

0 comments on commit 361f9c5

Please sign in to comment.