PayPal Interview Question for Quality Assurance Engineers


Country: United States
Interview Type: Phone Interview




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

import java.util.Set;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Iterator;

public class test{
    
    public static Map<String,List<String>> mapping(Map<String,String> map){
        Map<String,List<String>> hm=new HashMap<>();
        List<String> listRob=new ArrayList<>();
        List<String> listJohn=new ArrayList<>();
        Set<String> set=map.keySet();
        String val,temp;
        Iterator<String> it=set.iterator();
        while(it.hasNext()){
            val=it.next();
            temp=map.get(val);
            if(temp=="Rob"){
                listRob.add(val);
                hm.put("Rob",listRob);
            }
            if(temp=="John"){
                listJohn.add(val);
                hm.put("John",listJohn);
            }
        }
        return hm;
    }
    
    public static void main(String[] args){
        Map<String,String> map=new HashMap<>();
        map.put("Java","John");
        map.put("C#","Rob");
        map.put("Ruby","John");
        map.put("Rails","Rob");
        mapping(map).forEach((key,value)->System.out.println(key+"->"+value));
    }
}

- TurboMap June 26, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class T1 {

public static void main(String[] args) {
Map <String, String> book = new HashMap();
Map <String, List<String>> result = new HashMap();

book.put("Java", "John");
book.put("C#", "Rob");
book.put("Ruby", "John");
book.put("Rails", "Rob");

result.put("John", new ArrayList<String>());
result.put("Rob", new ArrayList<String>());



for (Map.Entry<String, String> entry : book.entrySet()) {


if(entry.getValue().equals("John")) {

result.get("John").add(entry.getKey());
}

if(entry.getValue().equals("Rob")) {

result.get("Rob").add(entry.getKey());
}

}

System.out.println(" Map Elements");
System.out.print("\t" + result);

}

}

- Thayse Alencar June 27, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

from collections import defaultdict

d={'Java':'John','C#':'Rob','Ruby':'John','Python':'John'}
newdict=defaultdict(list)

for i in d:
newdict[d[i]].append(i)
print newdict.items()

- Shweta Aggarwal July 18, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.*;
public class PaypalAssignment {

public static void main(String[] args)
{
// TODO Auto-generated method stub

Map<String,String> bookMap=new HashMap<String,String>();
Map<String,ArrayList> newArrayMap=new HashMap<String,ArrayList>();
HashSet set=new HashSet();
ArrayList list=new ArrayList();
ArrayList list2=new ArrayList();
String key;

bookMap.put("C#", "John");
bookMap.put("Java", "Rob");
bookMap.put("Ruby", "John");
bookMap.put("JScript", "Rob");

for(Map.Entry<String,String> entry:bookMap.entrySet())
{
if(!set.contains(entry.getValue()))
{
set.add(entry.getValue());
}
switch(entry.getValue())
{
case "John":
list.add(entry.getKey());
newArrayMap.put(entry.getValue(), list);
break;
case "Rob":
list2.add(entry.getKey());
newArrayMap.put(entry.getValue(), list2);
break;
default:
break;
}
}

Set set1=newArrayMap.entrySet();
Iterator i=set1.iterator();

while(i.hasNext())
{
System.out.println(i.next());
}

}
}

- Manoj Kumar M July 19, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.*;
public class PaypalAssignment {

public static void main(String[] args)
{
// TODO Auto-generated method stub

Map<String,String> bookMap=new HashMap<String,String>();
Map<String,ArrayList> newArrayMap=new HashMap<String,ArrayList>();
HashSet set=new HashSet();
ArrayList list=new ArrayList();
ArrayList list2=new ArrayList();
String key;

bookMap.put("C#", "John");
bookMap.put("Java", "Rob");
bookMap.put("Ruby", "John");
bookMap.put("JScript", "Rob");

for(Map.Entry<String,String> entry:bookMap.entrySet())
{
if(!set.contains(entry.getValue()))
{
set.add(entry.getValue());
}
switch(entry.getValue())
{
case "John":
list.add(entry.getKey());
newArrayMap.put(entry.getValue(), list);
break;
case "Rob":
list2.add(entry.getKey());
newArrayMap.put(entry.getValue(), list2);
break;
default:
break;
}
}

Set set1=newArrayMap.entrySet();
Iterator i=set1.iterator();

while(i.hasNext())
{
System.out.println(i.next());
}
}
}

- Manoj Kumar M July 19, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

package dataStrucures.practicals;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

public class PaypalAssignment {
public static void main(String a[]){
Map<String,String> map=new ConcurrentHashMap<>();
map.put("Java","John");
map.put("C#","Rob");
map.put("Ruby","John");
map.put("Rails","Rob");
map.put("Junit","John");
map.put("python","Rob");
map.put("C++","John");
map.put(".Net","Rob");
mapping(map).forEach((key,Value)-> System.out.println(key+":"+Value));
}

public static Map<String, List> mapping(Map<String, String> booksMap){
Map<String, List> finalMap= new HashMap();
Set<String> keys = booksMap.keySet();
Iterator<String> it=keys.iterator();
while(it.hasNext()){
String key_value = it.next();
String temp_value = booksMap.get(key_value);
List<String> values = new ArrayList<String>();
for (Map.Entry<String, String> entry : booksMap.entrySet()) {
if(entry.getValue().equals(temp_value)) {
values.add(entry.getKey());

}

}

finalMap.put(temp_value, values);

}

return finalMap;
}


}

- Suman August 05, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;

public class Hashmap {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
HashMap m = new HashMap<String, String>();
HashMap<String, ArrayList> resultMap = new HashMap<String, ArrayList>();

m.put("Ruby", "Jhon");
m.put("Java", "Jhon");
m.put("C#", "Rob");
m.put("Python", "Rob");

m.forEach((key, value) -> {
if (!resultMap.containsKey(value)) {
ArrayList l = new ArrayList<>();
l.add(key);
resultMap.put((String) value, l);
} else {
resultMap.get(value).add(key);
}

});

resultMap.forEach((i,k)->{System.out.println(i+","+k);});

}
}

- Rahil August 15, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;

public class Hashmap {
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		HashMap m = new HashMap<String, String>();
		HashMap<String, ArrayList> resultMap = new HashMap<String, ArrayList>();

		m.put("Ruby", "Jhon");
		m.put("Java", "Jhon");
		m.put("C#", "Rob");
		m.put("Python", "Rob");

		m.forEach((key, value) -> {
			if (!resultMap.containsKey(value)) {
				ArrayList l = new ArrayList<>();
				l.add(key);
				resultMap.put((String) value, l);
			} else {
				resultMap.get(value).add(key);
			}

		});
		
		resultMap.forEach((i,k)->{System.out.println(i+","+k);});

	}
}

- Rahil August 15, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;

public class Hashmap {
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		HashMap m = new HashMap<String, String>();
		HashMap<String, ArrayList> resultMap = new HashMap<String, ArrayList>();

		m.put("Ruby", "Jhon");
		m.put("Java", "Jhon");
		m.put("C#", "Rob");
		m.put("Python", "Rob");

		m.forEach((key, value) -> {
			if (!resultMap.containsKey(value)) {
				ArrayList l = new ArrayList<>();
				l.add(key);
				resultMap.put((String) value, l);
			} else {
				resultMap.get(value).add(key);
			}

		});
		
		resultMap.forEach((i,k)->{System.out.println(i+","+k);});

	}
}

- Rahil August 15, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;

public class Hashmap {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
HashMap m = new HashMap<String, String>();
HashMap<String, ArrayList> resultMap = new HashMap<String, ArrayList>();

m.put("Ruby", "Jhon");
m.put("Java", "Jhon");
m.put("C#", "Rob");
m.put("Python", "Rob");

m.forEach((key, value) -> {
if (!resultMap.containsKey(value)) {
ArrayList l = new ArrayList<>();
l.add(key);
resultMap.put((String) value, l);
} else {
resultMap.get(value).add(key);
}

});

resultMap.forEach((i,k)->{System.out.println(i+","+k);});

}
}

- Rahil August 15, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

mybook={}

print("Enter the no of keys u want to enter")
n=int(input())

for i in range(0,n):
    key=input("Enter the key")
    value=input("Enter the value")

    mybook[key]=value

print(mybook)

authors={}
key_list=[]
used=[]

key_list=mybook.keys()
for i in key_list:
    v=mybook.get(i)
    if v not in used:
        used.append(v)
        authors.setdefault(v,[])
    authors[v].append(i)
    

print(authors)

- RIJU MUKHERJEE September 13, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

mybook={}

print("Enter the no of keys u want to enter")
n=int(input())

for i in range(0,n):
    key=input("Enter the key")
    value=input("Enter the value")

    mybook[key]=value

print(mybook)

authors={}
key_list=[]
used=[]

key_list=mybook.keys()
for i in key_list:
    v=mybook.get(i)
    if v not in used:
        used.append(v)
        authors.setdefault(v,[])
    authors[v].append(i)
    

print(authors)

- RIJU MUKHERJEE September 13, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

mybook={}

print("Enter the no of keys u want to enter")
n=int(input())

for i in range(0,n):
key=input("Enter the key")
value=input("Enter the value")

mybook[key]=value

print(mybook)

authors={}
key_list=[]
used=[]

key_list=mybook.keys()
for i in key_list:
v=mybook.get(i)
if v not in used:
used.append(v)
authors.setdefault(v,[])
authors[v].append(i)


print(authors)

- Anonymous September 13, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

var data2 = [{'Java' : 'John'},{'C#':'Rob'},{'Ruby':'John'},{'Rails':'Rob'},{'Fuss':'Ruchi'},{'stud':'Sud'}];
function getUniqueBook(){
var newArr = data2.reduce((accum, item) => {
for(book in item){
var temp = item[book];
if(accum[temp])
accum[temp] = [...accum[temp],book]
else
accum[temp] =[book]
}
return accum;
},{});
console.log(newArr);
}

- retina January 11, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def return_map(ip):

    op = {}

    for key, val in ip.items():
        if val in op.keys():
            op[val].append(key)
        else:
            op.setdefault(val, [])
            op[val].append(key)
    return op


# drive program
book_map = {
    "Java": "John",
    "C#": "Rob",
    "Ruby": "John",
    "Rails": "Rob"}

op = return_map(book_map)
print(op)

- Anonymous January 14, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def return_map(ip):

    op = {}

    for key, val in ip.items():
        if val in op.keys():
            op[val].append(key)
        else:
            op.setdefault(val, [])
            op[val].append(key)
    return op


# drive program
book_map = {
    "Java": "John",
    "C#": "Rob",
    "Ruby": "John",
    "Rails": "Rob"}

op = return_map(book_map)
print(op)

- Darshan N S January 14, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Map<String, String> map = new HashMap<>();
map.put("Java", "John");
map.put("C#", "Rob");
map.put("Ruby", "John");
map.put("Rails", "Rob");
map.put("Python", "John");
map.put("Go", "Rob");
Map<String, Set<String>> mapSet = new HashMap<>();
Set<String> languages = null;
for (String str : map.keySet()) {
String author = map.get(str);
Set<String> set=mapSet.getOrDefault(author,new HashSet<String>());
set.add(str);
mapSet.put(author,set);
}
mapSet.forEach((key,value)->{
System.out.println(key+" "+value);
});
}

- Ashlin K November 10, 2020 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Map<String, String> map = new HashMap<>();
map.put("Java", "John");
map.put("C#", "Rob");
map.put("Ruby", "John");
map.put("Rails", "Rob");
map.put("Python", "John");
map.put("Go", "Rob");
Map<String, Set<String>> mapSet = new HashMap<>();
Set<String> languages = null;
for (String str : map.keySet()) {
String author = map.get(str);
Set<String> set=mapSet.getOrDefault(author,new HashSet<String>());
set.add(str);
mapSet.put(author,set);
}
mapSet.forEach((key,value)->{
System.out.println(key+" "+value);
});
}

- Ashlin K November 10, 2020 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Map<String, String> map = new HashMap<>();
        map.put("Java", "John");
        map.put("C#", "Rob");
        map.put("Ruby", "John");
        map.put("Rails", "Rob");
        map.put("Python", "John");
        map.put("Go", "Rob");
        Map<String, Set<String>> mapSet = new HashMap<>();
        Set<String> languages = null;
        for (String str : map.keySet()) {
            String author = map.get(str);
            Set<String> set=mapSet.getOrDefault(author,new HashSet<String>());
            set.add(str);
            mapSet.put(author,set);
        }
        mapSet.forEach((key,value)->{
            System.out.println(key+" "+value);
        });
    }

- Ashlin K November 10, 2020 | 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