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.

- SumitGaur April 25, 2014 | Flag Reply
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'.
2. set.add(list1.items);
3. set.add(list2.items);
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)

- Anonymous November 30, 2014 | Flag Reply
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?

- Anonymous April 25, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Why not use a hash set to implement it.

- kanika June 25, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

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

- Anony November 26, 2014 | Flag
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++)
		{
			if (hashSet.add(l1[i].toLowerCase()))
			{
				combinedList.add(l1[i]);
			}
		}

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

		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);
	}
}

- Mahmoud El-Maghraby June 29, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
2
of 2 votes

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

- Anonymouus September 16, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

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

- xx April 08, 2015 | Flag
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.

- Raj April 26, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

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

- left4dead October 02, 2014 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Use Trie.

- msmajeed9 May 25, 2014 | Flag Reply


Add a Comment
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.

Learn More

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.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More