bazinga
BAN USER- 0of 2 votes
Answerswrite a function that calculates the minimum number of meeting rooms that can accommodate given schedules
- bazinga in United States
input: same
output: # of rooms
Also back to back events are allowed e.g. {2,5} {5,9} correct o/p:1| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 2of 2 votes
Answerswrite a function that detects conflicts in given meeting schedules
- bazinga in United States
input: a list of intervals, [(s1, e1), (s2, e2), ]
output: return True if there's any conflict, False otherwise| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 0of 0 votes
AnswersGiven a sorted array of size n+1 having all the elements from the range 1..n with only one duplicate element, find the duplicate element.
- bazinga in United States
e.g. if n is 10
then the array could be.
1 2 3 4 4 5 6 7 8 9 10
where 4 is the duplicate element.| Report Duplicate | Flag | PURGE
Software Engineer / Developer Algorithm
class Event{
int time;
EventType type;
Event(int time, EventType type){
this.time = time;
this.type = type;
}
}
enum EventType{
int cardinality;
EventType(int cardinality){
this.cardinality = cardinality;
}
END(0),BEGIN(1);
}
public int getMinimumRooms(List<Interval> slots){
if(slots == null || slots.size() <1){
return 0;
}
List<Event> events = new ArrayList<Event>();
for(Interval interval:slots){
events.add(new Event(interval.getStartTime(), EventType.BEGIN);
events.add(new Event(interval.getEndTime(), EventType.END);
}
Collections.sort(events,new Comparator<Event>(){
public int compareTo(Event one , Event two){
if(one.time == two.time){
return one.cardinality - two.cardinality;
}
return one.time - two. time;
}});
int roomCount = 0;
int max =0;
for(Event anEvent:events){
if(event.type == BEGIN){
++roomCount;
}else{
--roomCount;
}
if(max<roomCount){
max = roomCount;
}
}
return max;
}
Repsarciasonda, Associate at ABC TECH SUPPORT
Computer forensics investigators, also known as computer forensics specialists, computer forensics examiners, government , accounting firms, law firms, banks, and software ...
- bazinga March 24, 2015