注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
本帖最后由 alchuang 于 2022-11-21 16:42 编辑
Hackerrank OA 請大神求最優解
Question 1: Generic Validation:
Your task is to write a function to validate a data structure that represents the reporting hierarchy of an organization. Here's an example:- const employees = [
- { name: 'alice',
- title: "ceo",
- salary: 100,
- reports: [{
- name: "bob",
- title: "cfo",
- salary: 10,
- reports: [{
- name: 'zorp',
- title:"controller",
- salary: 40
- }],
- }],
- }]
复制代码 At the top level, we have a list of employees with vaquot; }
if a property does not belong, you should return
{ ok: false, message: "property ${prop} does not belong" }
complete the validate function- function validate(employees, schema) {
- // Complete validate function here
- return { ok: true, message: "success" }
- }
复制代码 |