Epic Systems Interview Question for Software Engineer / Developers

Country: United States
Interview Type: Written Test

Comment hidden because of low score. Click to expand.
9
of 9 vote

This can be accomplished using a HashSet as it does not allows duplicate elements. Suppose there are m elements in list1 and n elements in list2; The overall time complexity will be linear and space will be m+n.

Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
2
of 2 vote

``````Solution 1:
1. Initialize a HashSet 'set'.
4. return set;
Time: O(m+n);
Space: O(m+n);

Solution 2:
n = list1.size();
m = list2.size();
1. Sort list1. O(nlogn)
2. Sort list2. O(mlogm)
3. Merge (list1,list2). O(n+m)
Time: O(nlogn + mlogm + n + m) = O(nlogn + mlogm)
Space: O(1)``````

Comment hidden because of low score. Click to expand.
1
of 1 vote

Clarification.

One roommate says 2 bottles of milk, and other says 1 bottle. How to choose?

Comment hidden because of low score. Click to expand.
0

Why not use a hash set to implement it.

Comment hidden because of low score. Click to expand.
0

I'm first roomate's friend, the second bottle of milk if for me

Comment hidden because of low score. Click to expand.
1
of 1 vote

``````import java.util.ArrayList;
import java.util.HashSet;

public class CombineLists
{
public static ArrayList<String> getCombinedList(String[] l1, String[] l2)
{
HashSet<String> hashSet = new HashSet<String>();
ArrayList<String> combinedList = new ArrayList<String>();

for (int i = 0; i < l1.length; i++)
{
{
}
}

for (int i = 0; i < l2.length; i++)
{
if (!hashSet.contains(l2[i].toLowerCase()))
{
}
}

return combinedList;
}

public static void main(String[] args)
{
String[] l1 = { "a", "b", "c", "d", "e" };
String[] l2 = { "f", "b", "g", "d", "h" };

ArrayList<String> combinedList = getCombinedList(l1, l2);
for (String item : combinedList)
System.out.println(item);
}
}``````

Comment hidden because of low score. Click to expand.
2

Why you need a separate arraylist to print, u can iterate through Hashset itself using Iterator.
Saves space

Comment hidden because of low score. Click to expand.
0

I think there is no need to use another Hash Set. While adding elements of l2 after adding l1 in the combined arraylist , just check if it contains any element of l2 in it.If not add else ignore. You are wasting extra memory for hashset

Comment hidden because of low score. Click to expand.
0
of 0 vote

Perhaps not the quantity and only the Item names are considered. This can be seen as a merging of two sorted list such that the final list is also sorted avoiding any duplicates.

Comment hidden because of low score. Click to expand.
0

It is not equivalent to merging two sorted list. This problem is just to remove duplicates from two unsorted arrays/lists.

Comment hidden because of low score. Click to expand.
-1
of 1 vote

Use Trie.

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.