注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
题目概述:
一共四道题,限时 1.5 小时,实现一个类管理 recipe(模拟题 + 哈希表/排序)
Create a digital recipe manager where users can store and organize their cooking recipes. This will be a 4-level progressive task, and efficiency is not required; any solution that passes the tests is acceptable. 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. You are not required to provide the most efficient implementation. Any code that passes the unit tests is sufficient. You can execute a single test case by running the following command in the terminal:
bash run_single_test.sh "<test_case_name>".
Requirements
Plan your design according to the level specifications below:
Level 1
Basic CRUD operations for managing recipes without any user-specific data.
- add_recipe(self, name: str, ingredients: list[str], steps: list[str]) -> str | None
复制代码
Adds a new recipe and returns ithistory entry withas the editor. This new entry is appended to the version history, keeping the original history immutable. Returns True if rollback is successful, False if the version does not exist, the recipe does not exist, or if rolling back would cause a name conflict with another existing recipe (case-insensitive). Note on and :
Whenis called, it creates a version history entry withset to.
Whenis called, it creates a version history entry withset to the user_id of the editor.
|