Boomerang Commerce Interview Question for Developer Program Engineers


Country: India
Interview Type: In-Person




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

Here the question is more about how to identify multiple user records belong to same user,
This is more of a idea generation and discussion type question rather than design....

Ex:

you have ("9893342233", "Eshwar", "eshwar@gmail.com" ), ("040-23554677", "Eshwar Prasad", "eshwar.prasad@work.com"),

Now identify both belong to same person and merge them / tag them to same person.

- Vib February 28, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

package design;
import java.util.*;
public class DemoPhoneContact {

	public static void main(String args[]){
		
		PhoneContact phone=new PhoneContact(new HashSet());
		
		User u1=new User("9945454545","Eshwar", "eshwar@gmail.com");
		User u2=new User("8877003681", "hari", "hari@gmail.com");
		User u3=new User("7788990034","prabha", "prabha@gmail.com");
		User u4=new User("8989898987", "arjun", "arjun@gmail.com");
		User u5=new User("9738383838", "kiran", "kiran@gmail.com");
		phone.addUser(u1);
		phone.addUser(u2);
		phone.addUser(u3);
		phone.addUser(u4);
		phone.addUser(u5);
		
		
		User user=phone.searchUser("eshwar@gmail.com");
		
		if(user!=null){
		
		System.out.println("UserDetails :: " + user.getName() +" ," + user.getEmail() + ", "+ user.getPhoneNumber());
		}else {
			
			System.out.println("Sorry number nor exist");
		}
	}
}

class PhoneContact {
	
	Set<User> set;
	
	public PhoneContact(Set<User> set){
		
		this.set=set;
	}
	
	public void addUser(User user){
		set.add(user);
	}
	
	public User searchUser(String name){
		
		Iterator<User> itr=set.iterator();
		User user=null;
		while(itr.hasNext()){
			User  myuser=itr.next();
			if(name.equalsIgnoreCase(myuser.getName())|| name.equalsIgnoreCase(myuser.getEmail())){
				
				user=myuser;
				break;
			}
		}
		
		return user;
		
	}
}

class User implements Comparable<String> {
	private String phoneNumber;
	private String name;
	private String email;
	
	public User(String phoneNumber, String name, String email){
		
		this.phoneNumber=phoneNumber;
		this.name=name;
		this.email=email;
	}
	public String getPhoneNumber() {
		return phoneNumber;
	}
	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((phoneNumber == null) ? 0 : phoneNumber.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		User other = (User) obj;
		if (phoneNumber == null) {
			if (other.phoneNumber != null)
				return false;
		} else if (!phoneNumber.equalsIgnoreCase(other.phoneNumber))
			return false;
		return true;
	}
	@Override
	public int compareTo(String arg0) {
		if(this.phoneNumber.compareTo(arg0)==0){
			return 0;
		}else {
		 
			return this.phoneNumber.compareTo(arg0);
		}
		
	}
	
	
}

- Eshwar February 15, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

We can use a Trie data structure here.
Store all the information of any user in object, lets say Contact. Now add the name of user in a Trie and nod at which name ends, store that user's object at this node and mark as a end of string.

Similarly we can add all information of that user like number, email id, company name in this Trie( yes, considering we have a space ) and store particular Conatact object at the end of every node where string ends.

Now do Trie string search and display all unique objects.

- Tushar August 01, 2015 | 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