ADP Lifion开发,考数据库和算法

白人小哥经理。形式是视频加coderpad。

【一】数据库设计和查询。

面试经过:一开始错了,后来在提示之下改对了。

教训:冷静下来,才能正常思考。
员工可以记录带薪休假请求并提交批准。 然后,经理可以接受或拒绝该请求。
像这样描述:“实体名称:字段1(类型),字段2(类型)”
(1)设计erd
(2)员工1先请假。员工2也想请假。查询员工1的可用范围,从而让两者的请假区间尽量不重叠。(最好画图说明) 

An employee can log a paid time off request and submit for approval. A manager can then accept or reject that request.

Describe like this: “Entity Name: Field 1 (Type), Field 2 (Type)”


3 entities:
employee(emp_id,..., request) y/n
manager(manager_id,fname/lname, dept,..., approval_or_not) y/n
pay_time_off(emp_id, manager_id, type, approval_or_not, duration/timeslot, start_date, end_date)

//manager needs a pay time off
emp_id = manager's id
manager_id = manager's manager's id
1,3


EMPID (PK)    FIRST_NAME    REQUEST
1         John             y
2         Jack             y
4         Emily

MANAGER_ID (PK)    FIRST_NAME    DEPT
3                   Jane     
1                   John(1)


John (Manager) -> Jane
Jack           -> John 

2 Requests:
  1. John
  2. Jack
  

John: 

Examples:

Emily
1/1/2021 - 1/2/2021 APPROVED


  - Reviewing a request:
    input: Jack    1/15/2021 - 2/1/2021
    
    @input_startDate
    @input_endDate
    
    SELECT EMP_ID FROM pay_time_off
    WHERE approval_or_not = 'Y'
    AND (start_date >= startDate OR end_date <= endDate) //RANGE
    
View Code

 

【二】编码

面试经过:没思路,然后自言自语画了个图。开始用的暴力解法,提示后优化了一下,也不知道对不对。
考虑一个聚会,管家在两个单独的列表中记录客人的出入时间。 查找在同一时间在房子里的最大客人数量。 (请注意,寄存器中的条目没有任何特定顺序)。
例如:
entry:[1、5、7],表示来宾在1进入,然后在5进入另一个,在7进入第三
exit:[8、6、9],表示在1处进入8的宾客,在5处进入6的宾客,6宾客和在9进入的宾客。

我觉得我的想法很自然,gfg的想法很做作。那就这样吧!

教训:有了大概思路后先确认一下。这是三个问中的第一问

答案:https://www.geeksforgeeks.org/find-the-point-where-maximum-intervals-overlap/ 

Consider a party, where the housekeeper is keeping a register of guests’ entry and exit times in two separate lists. Find the maximum number of guests that were in the house at the same time. (Note that the entries in the register are not in any particular order).

For example:
Entries: [1, 5, 7], meaning a guest entered at 1, then another at 5, and a third at 7
Exits: [8, 6, 9], meaning the guest who entered at 1 left at 8, the guess who entered at 5, left at 6, and the guest who entered at 7, left at 9

+ + - + - -

2


//interval [1,8] [5,6][7,9] 
//merge - minimum common interval

time = 1, count_of_time_1 = 1
time = 2, count_of_time_2 = 1
...
time = 9, count.. = 1

for (int time = 0; time < max; time++) {
  //judge if a guest come in
  if (Entries.contains(time)) {
    count++;
    max_count = (max_count, count);
  }else (Exits.contains(time)) {
    count--;
    max_count = (max_count, count);
  }
}

return max_count;
View Code

 

【三】编码

面试经过:说了暴力解法没有写,写了优化了一下的解法,也不知道对不对。
编写一个给定整数数组(允许重复,不排序)的函数,该函数确定整数的连续性是连续的,还是数组中最小和最大整数之间存在间隙。 如果整数是连续的,则函数应输出true;如果存在间隔,则应输出false。

例如:
输入:[1、3、2、2],输出为true
输入:[5、6、7、8],输出为true
输入:[1、4、3、3],输出为false,因为我们缺少2]

Write a function that given an array of integers (duplicates allowed, not sorted) determines whether the progression of integers is continuous, or there are gaps between the smallest and largest integers in the array. The function should output true, if the integers are continuous, and false, if there is a gap.

For example:

Input: [1, 3, 2, 2], outputs true
Input: [5, 6, 7, 8], outputs true
Input: [1, 4, 3, 3], outputs false, since we’re missing a 2]

//loop thru ,return false?
n


[1, 99999999999999999]
max_value
//2
for (int i = start; i < end; i++) {
  int bigger_int = (i + 1); //2
  if ((bigger_int < end) && (!Input.contains(Input)))   
    return false;
}

worst: n
best: 1
View Code

一个我觉得看答案才能想到的优化,用和去减去:https://leetcode.com/problems/missing-number/discuss/69786/3-different-ideas%3A-XOR-SUM-Binary-Search.-Java-code 

所以到最后也不知道自己做的到底对不对,面试官是否满意。

教训:有了大概思路后先确认一下。这是三个问中的第一问。

 

感想:

好多时候问的算法题真的都是弱智级别的,但是如果紧张,就什么都想不出来 然后瞎说
面试完硬是大冬天出了一胳肢窝的汗……
没有第一直觉的灵感(需要培养🧫,把从暴力到优化代码作为自己的基本素质)。感觉我没有把一起啊面挂的东西好好内化、学懂,而且,怎么才能有效地增加内化呢?是不是要搞个数组专题?
抱着一种“和同事、同学聊天讨论”的心情,会放松多了,能够正常思考。成年人的世界真的好难啊:明明想要快点结束🔚失业期,可还是得装出毫不在意得样子。唉🙍!
今天的面试没有三3️⃣个问!都是我一个人在自言自语,到最后面试官也不高兴了,就挺尴尬的。
除夕夜还白嫖了个面试,哪怕挂了也虽败犹荣,真充实呢。

 

说真的,面试还是真的挺看运气的。
不可能人人都过五关斩六将🤺进公司的。我个人的3个面试都是水进去的……
提高客观实力固然重要。可是多面试多碰也很重要。说不定哪天哪家瞎了眼的公司让你水进去了呢?

 

posted @ 2021-02-12 05:55  苗妙苗  阅读(118)  评论(0)    收藏  举报