mikeldi10
BAN USER- 0of 0 votes
AnswersHaving a home-defined linked list with the following structure, where the next will point to the next node in the list and the random will point to a random node in the list (not null).
- mikeldi10 in United States
Create a copy of the structure (the data field in each node is not unique for different nodes):
/*
Example:
Having the list:
1 -> 2 -> 3 -> X
With random pointers to:
1: 3
2: 2
3: 1
Create the list:
1' -> 2' -> 3' -> X
1': 3'
2': 2'
3': 1'
*/
class Node {
int data;
Node next;
Node random;
}| Report Duplicate | Flag | PURGE
Facebook Algorithm - 1of 1 vote
AnswersMake a function that shows the common elements in two arrays. Part 2: With duplicates (small explanation). Part3: without duplicates
Answer:
- mikeldi10 in United States for Amazon Instant Videoint[] intersect(int[] array1, int[] array2){ if(array1.lentgh == 0 || array2.length == 0) return {}; Set<Integer> set = new HashSet<Integer>(); for(int i = 0; i < array1.length ; i++){ set.put(array1[i]); } List<Integer> list = new ArrayList<Integer>(); for(int i = 0;i < array2.length ; i++){ if(set.contains(array2[i])){ //map.put(map.get(array2[i])-1); //short explanation of how to do it with dupplicates set.remove(array2[i]); list.add(array2[i]); } } return list.toArray(); }
| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 2of 4 votes
AnswersHaving a table Genre with two colums (Id, Genre) make an SQL Query that finds the Ids with the genre Action and Comedy. (those will have multiple lines for each Id)
Answer:
- mikeldi10 in UK for Amazon Instant Videoselect g.id from (select id from genre where genre = 'Action') x, genre as g where g.id = x.id and genre = 'Commedy'
| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer SQL - 0of 0 votes
AnswersHow would you do to sort different files. All the data does not fit in memory.
- mikeldi10 in UK for Amazon Instant Video
Answered: Merge sort like method, where you sort each file. For the end merge, read some data from each file (make sure you have at least one from each file) and sort them| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 1of 1 vote
Answers// merge sorted arrays 'a' and 'b', each with 'length' elements,
- mikeldi10 in Spain
// in-place into 'b' to form a sorted result. assume that 'b'
// has 2*length allocated space.
// e.g. a = [1, 3, 5], b = [2, 4, 6] => b = [1, 2, 3, 4, 5, 6]
//how to do it without rearanging the b array| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm
Repcarmenrhargis, Associate at Achieve Internet
Hi, I am Gladys, I live in Florida, USA, I am working as a project manager in a Life’s ...
Result:
- mikeldi10 June 11, 201411111
1112
113
122
14
23
5