注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
无算法题,三道实际场景应用题,主要考察代码准确性
1. You are required to write a POST API endpoint that is responsible for creating users and saving them into
mocked-up database.
Requirements
In order to satisfy the task's requirements you must implement a POST /users API endpoint which will:
accept std: :string route and payload in JSON format;
accept two properties in the payload: name and age ;
return status code 400 if the route is incorrect (different from /users );
return status code 400 if either name or age is missing;
return status code 400 if either age is not a number or name is not a string;
return status code 400 if name is longer than 32 characters;
return status code 400 if age is less than 16
create a User object using validated data;
call the save function (provided in the header file) if none of the above conditions fail, which will save
the User object in the mocked-up database and return a 201 status code.
2. You are given a string containing a detailed list of files. Your task is to evaluate a simple query on a certain
subset of these files.
The string consists of N lines separated by end-of-line characters (ASCII code 10). Each line contains
information about one file, grouped in five columns: owner, perm, date, size and name (in that order). The
columns (except for the last one) have fixed lengths and are separated by one space. They have the
following formats and meanings:
Column perm has length 3 and contains information about permissions. It contains three
characters: they control respectively whether reading, writing and execution of the file is
permitted. The characters are respectively r, w and x if these operations are permitted;
otherwise they are -.
Column owner has length 6 and contains a string representing the name of the user who
created the file. The name is case sensitive and aligned to the left.
Column size has length 10 and contains the size of the file in bytes. The size is less than 231
bytes and is aligned to the right.
Column date has length 11 and contains the last modification date of the file in the format "dd
MMM yyy". The names oft;,
"10S", "JC" ]
}
Set 5: suit
●Name: suit”
Description: Five cards sharing the same suit; the ranks do not matter. If there are multiple
ways to choose five cards with the same suit, choose any set with the highest suit. The order
of the suits (from the highest to the lowest)is S, H, D, C.
For example, for cards= ["2D", "4D", "6D", "8D","9D", "AC", "KC", "QC", "JC", "7C], one of the correct
results is:
{
set_ name
suit",
selected_ cards" = [ "2D" ,
"4D", ”6D"
"8D","9D" ]
}
Set 6: a triple and a pair
Name: "a triple and a pair"
Description: Five cards, consisting of a triple (three cards of the same rank) and a pair (two
cards of the same rank). If there are multiple ways to choose this set, choose one with the
highest rank of the triple, then one with the highest rank of the pair. The suits do not matter.
For example, for cards = ["10D", "10H", "10C" "2S", "2H", "2D", "JH", "JC"], one of the correct results is:
”set_ name”
= "a triple and a pair"
"selected_ cards" = [ "10D", "10H", "10C", ” JH",“ JC" ]
} |