Amazon Interview Question for SDE-2s


Country: India
Interview Type: In-Person




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

How about using pure object oriented design without involving DB here . As in, say one class (SwipeMachine) maintains a map with a pair of keys (date,EmpId) and values.

This class would then be a singleton class (or to be scalable, multiple classes when there are multiple swipmachines) , and as and when employees swip-in or swip-out, it adds values to the map

class compositeKey{
date d;
int empid;
compositeKey(date d1, int empid1) {
d = d1;
empid = empid1;
}
}
and then use this composite key to create a map of swip entries
Map<key1,string> swipMap = new HashMap <key1,string>;

Please let me know your thoughts.

- rsumankumar July 04, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Table :-

1. Employee ( id, name, email, password, manager_id )
2. Role_mapping ( id, employee_id, role_id )
3. Role ( id, role_name, city_name)
3. Attendance (id, employee_id, date, swap_in_time, swap_out_time)

for employee :-
select at.swap_in_time, at.swap_out_time from Attendance at inner join Employee emp on emp.id = at.employee_id where emp.email = "abc@example.com" and at.data = now();

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

1. employee ( id, name, email, password, manager_id, role_id)
2. role (id, name, city_name)
3. attendance( id, employee_id, swap_in_time, swap_out_time, date).

for employee :-
select at.swap_in_time, at.swap_out_time from attendance at inner join employee emp on emp.id = at.employee_id where emp.email = "abc@example.com" and at.date = now();

- Kapil June 26, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Pls correct if anything missed ..
Tables/Schemas: Employee(emp_Id, name, email, password,manager_id,role_id)
roles(role_id, role, city_name)
attendence(id,emp_Id,role_id,date,swap_in_time, swap_out_time)
Query :
SELECT a.swap_in_time,a.swap_out_time
FROM attendence a inner join employee e
inner join roles r
ON e.emp_Id = a.emp_Id and e.role_id = e.role_id
where r.role_name IN ('manager','employee',HR') ORDER BY swap_in_time,swap_in_time DESC;

UPDATE attendence a SET a.swap_in_time=<>, a.swap_in_time=<> where role_id IN (select role_id from roles where role IN ('manager','employee')

- Sudhanshu Sharma June 27, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

abc

- abc August 07, 2017 | 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