rockykumar1970
BAN USER- 0of 0 votes
AnswersWhy you use ChromeDriver as the below. Why cant it work as Firefox driver by simply creating a reference
- rockykumar1970 in India
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
WebDriver driver = new ChromeDriver();| Report Duplicate | Flag | PURGE
Ebay Software Engineer in Test Testing - 4of 4 votes
Answers
- rockykumar1970 in IndiaDesign a data structure which has following operations: 1. void add(e) 2. void delete(e) 3. boolean contains(e) 4. e getRandom() 5. e getMostRecent() All operations should be preferably O(1)
| Report Duplicate | Flag | PURGE
SumoLogic Software Engineer in Test - 1of 1 vote
AnswersKindly find the question below:
- rockykumar1970 in India
Design a data structure which has following operations:
1. void add(e)
2. void delete(e)
3. boolean contains(e)
4. e getRandom()
5. e getMostRecent()
All operations should be preferably O(1)| Report Duplicate | Flag | PURGE
SumoLogic Software Engineer in Test Algorithm
- 2 Answers Unable to post SumoLogic StartUp company interview questions, if anyone can post on my behalf will be thank ful
Unable to post SumoLogic StartUp company interview questions, if anyone can post on my behalf will be thank ful
- rockykumar1970 August 05, 2014
Question 1 :
Kindly find the question below:
Design a data structure which has following operations:
1. void add(e)
2. void delete(e)
3. boolean contains(e)
4. e getRandom()
5. e getMostRecent()
All operations should be preferably O(1)
Answer :
public class ValidateData
{
private HashMap<Object, Integer> hashMap = new HashMap<>();
private ArrayList<Object> list;
public ValidateData()
{
hashMap = new HashMap<>();
list = new ArrayList<>();
}
public void insert(Object object)
{
int index = list.size();
hashMap.put(object, index);
list.add(object);
}
public boolean contains(Object object)
{
return hashMap.containsKey(object);
}
public void delete(Object object)
{
if (hashMap.containsKey(object))
{
int index = hashMap.get(object);
int end = list.size() - 1;
Object o = list.get(end);
list.set(index, o);
list.remove(end);
hashMap.put(o, index);
hashMap.remove(object);
}
}
public Object getRandom()
{
Random rand = new Random();
int index = rand.nextInt(list.size());
System.out.println(list.get(index));
return list.get(index);
}| Flag | PURGE
public class ValidateData
{
private HashMap<Object, Integer> hashMap = new HashMap<>();
private ArrayList<Object> list;
public ValidateData()
{
hashMap = new HashMap<>();
list = new ArrayList<>();
}
public void insert(Object object)
{
int index = list.size();
hashMap.put(object, index);
list.add(object);
}
public boolean contains(Object object)
{
return hashMap.containsKey(object);
}
public void delete(Object object)
{
if (hashMap.containsKey(object))
{
int index = hashMap.get(object);
int end = list.size() - 1;
Object o = list.get(end);
list.set(index, o);
list.remove(end);
hashMap.put(o, index);
hashMap.remove(object);
}
}
public Object getRandom()
{
Random rand = new Random();
int index = rand.nextInt(list.size());
System.out.println(list.get(index));
return list.get(index);
}
- rockykumar1970 August 18, 2014