You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Understand what the interviewer is asking for by using test cases and questions about the problem.
Q
What is the desired outcome?
To find the list of artifacts common to both time periods.
What input is provided?
Two lists of strings, artifacts1 and artifacts2.
P-lan
Plan the solution with appropriate visualizations and pseudocode.
General Idea: Use sets to find the intersection of the two lists, which gives the common artifacts.
1) Convert `artifacts1` and `artifacts2` to sets.
2) Find the intersection of the two sets.
3) Convert the resulting set back to a list and return it.
⚠️ Common Mistakes
Not converting the sets back to a list before returning.
I-mplement
deffind_common_artifacts(artifacts1, artifacts2):
# Convert the lists to sets to find the intersectionset1=set(artifacts1)
set2=set(artifacts2)
# Find common artifacts using set intersectioncommon_artifacts=set1&set2# Convert the result back to a listreturnlist(common_artifacts)