Ramp Intern 的 Online Assessment 是一个CodeSignal 的 Industry Coding Framework Assessment.
问题不算太难,但不过花的时间特别多,感觉做不完。
一共4个level,每个都是在前面问题基础上加新问题。
前面一个level不得满分就不能进入下一个,我做到第三个没来的急做完,第四道没看见, 感觉凉凉了
1 - 3 level 题目如下:
Instructions
Your task is to implement a simplified version of a program registering the working hours of contract workers at a facility. All operations that should be supported by this program are described below.
Solving this task consists of several levels. Subsequent levels are opened when the current level is correctly solved. You always have access to the data for the current and all previous levels.
Requirements
Your task is to implement a simplified version of a program registering the working hours of contract workers at a facility. Plan your design according to the level specifications below:
• Level 1: The working hours register program should support adding workers to the system, registering the time when workers enter or leave the office and retrieving information about the time spent in the office.
• Level 2: The working hours register program should support retrieving statistics about the amount of time that workers spent in the office.
• Level 3: The working hours register program should support promoting workers, assigning them new positions and new compensation. The program should also support calculating a worker's salary for a given period.
• Level 4: The working hours register program should support setting time periods to be double-paid.
To move to the next level, you need to pass all the tests at this level.
Note
You will receive a list of queries to the system, and the final output should be an array of strings representing the returned values of all queries. Each query will only call one operation.
Level 1
Introduce operations for adding workers, registering their entering or leaving the office and retrieving information about the amount of time that they have worked.
• ADD_WORKER <workerId> <position> <compensation> — should add the workerId to the system and save additional information about them: their position and compensation. If the workerId already exists, nothinnothing happens and this operation should return an empty string
Examples
The example below shows how these operations should work (the section is scrollable to the right):
the output should be ["true", "registered", "registered", "success", "registered", "invalid_request", "registered", "registered", "35000", "John(0)", "registered", "250", "John(75)", "", "45500", "0"].
Input/Output
• [execution time limit] 4 seconds (py3)
• [memory limit] 1 GB
• [input] array.array.string queriesAn array of queries to the system. It is guaranteed that all the queries parameters are valid: each query calls one of the operations described in the description, all operation parameters are given in the correct format, and all conditions required for each operation are satisfied.Guaranteed constraints:1 ≤ queries.length ≤ 500.
• [output] array.stringAn array of strings representing the returned values of queries.
[Python 3] Syntax Tips
# Prints help message to the console# Returns a stringdefhelloWorld(name): print("This prints to the console when you Run Tests") return"Hello, "+ name
一些tips:
- 一开始要想好用什么Data Structure能让后面的题目更好做,以免后来需要refactor。我用的是一个Worker的structure加上dictionary,key是worker id, value 是 worker object
- 有很多时候要从int 换到 str, str 换到 int, 如果你用str type的 integers 做comparison的话得到的答案会是错的
- 复习一下filter 还有 join function 会很有用
- 时间真的很紧,开始之前记得补觉。。。。
新人求米啊!!第一次发帖,万分感谢施舍!!! |