Interview Question for Developer Program Engineers

Country: United States

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

Some ideas:
Talklink *Morning_Track[track_number];
Talklink *Afternoon_Track[track_number];
Do a basket sort to all talk, struct talk{name, time}, index is its time, so there can be talkElem[56], means time is ranged from 60 to 5;
The TalkLink can be established like time schedule, select from long time to short
So quite different.

- huahznz May 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
of 0 vote

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class Test {
String LUNCH_TIME = "12:00PM";
String END_OF_DAY = "05:00PM";

public List<TrackInfo> readFile(BufferedReader reader) throws IOException {
TrackInfo trackInfo=null;
List<TrackInfo> trackList = new ArrayList<TrackInfo>();
String line;
while((line = reader.readLine())!= null){
trackInfo = new TrackInfo();
if("lightning".equalsIgnoreCase(line.substring(line.lastIndexOf(" ")+1))){
trackInfo.setEventTime(line.substring(line.lastIndexOf(" ")+1));
trackInfo.setEventDesc(line.substring(0, line.lastIndexOf(" ")));

return trackList;

public Map<String, List<String>> processEventTime(List<TrackInfo> trackInfo) {
Calendar cal = new GregorianCalendar();
String SIMPLE_DATE_FORMAT= "h:mma";
int HOUR_OF_DAY= 9;
int MIN= 0;
SimpleDateFormat sdf = new SimpleDateFormat(SIMPLE_DATE_FORMAT);
cal.set(Calendar.HOUR_OF_DAY, HOUR_OF_DAY);
cal.set(Calendar.MINUTE, MIN);
String startTime;
String finishTime;

int track =1;
List<String> eventTime = new ArrayList<String>();
Map<String, List<String>> confRoomData = new HashMap<String, List<String>>();
for(TrackInfo trackData: trackInfo){
startTime = sdf.format(cal.getTime());
finishTime = getFormattedTime(trackData.getEventTime(), cal, sdf);
String flag = getTimeDiff(startTime, finishTime);
eventTime.add(flag+": LUNCH");
int minute = Integer.valueOf(trackData.getEventTime().replaceAll("min", ""));
cal.add(Calendar.MINUTE, -cal.getTime().getMinutes());
cal.add(Calendar.MINUTE, 60);
eventTime.add(sdf.format(cal.getTime())+": "+trackData.getEventDesc());
cal.add(Calendar.MINUTE, minute);
}else if(END_OF_DAY.equals(flag)){
eventTime.add(startTime+": Networking Event");
cal.set(Calendar.HOUR_OF_DAY, HOUR_OF_DAY);
cal.set(Calendar.MINUTE, MIN);
confRoomData.put(("track_"+track), eventTime);
eventTime = new ArrayList<String>();
eventTime.add(sdf.format(cal.getTime())+": "+trackData.getEventDesc());
finishTime = getFormattedTime(trackData.getEventTime(), cal, sdf);
eventTime.add(startTime+": "+trackData.getEventDesc());
confRoomData.put(("track_"+track), eventTime);
return confRoomData;

* This method calculating time difference for Lunch time (12:00 pm) & end of day i.e. 05:00pm
* @input 'startEventTime' and 'finishEventTime'
* @return time difference as String
private String getTimeDiff(String startEventTime, String finishEventTime) {
DateFormat df = new SimpleDateFormat("h:mma");
try {
Date startTime = (Date) df.parse(startEventTime);
Date finishTime = (Date) df.parse(finishEventTime);
Date lunchTime = (Date) df.parse(LUNCH_TIME);
Date endOfDay = (Date) df.parse(END_OF_DAY);
if(finishTime.compareTo(lunchTime) == 0 && startTime.compareTo(lunchTime) > 0){
return LUNCH_TIME;
} else if(startTime.compareTo(lunchTime) == 0 && finishTime.compareTo(lunchTime) > 0){
return LUNCH_TIME;
} else if(startTime.compareTo(lunchTime) < 0 && finishTime.compareTo(lunchTime) > 0){
return LUNCH_TIME;
return END_OF_DAY;
} catch (Exception e) {
return "";

private String getFormattedTime(String eventTime, Calendar cal, SimpleDateFormat sdf) {
if(null != eventTime && !"".equals(eventTime)){
eventTime = eventTime.replaceAll("min", "");
cal.add(Calendar.MINUTE, Integer.valueOf(eventTime));

return sdf.format(cal.getTime());
public static void main(String[] args) {
Test test = new Test();
// Open the file that is the first command line parameter
FileInputStream fstream = new FileInputStream("D://mydocs//myText.txt");

// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);

BufferedReader br = new BufferedReader(new InputStreamReader(in));

List<TrackInfo> trackList = test.readFile(br);
//Close the input stream
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());


Here is the code .. but it has some problem there is a gap between pre lunch task and lunch task in the track_2

- Anonymous July 11, 2013 | Flag Reply

Add a Comment

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.


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


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