Problem: Work Schedule
Description:
An employee has to work exactly as many hours as they are told to each week, scheduling no more than a given daily maximum number of hours. On some days, the number of hours worked will be given. The employee gets to choose the remainder of their schedule, within the given limits.
A completed schedule consists of exactly 7 digits in the range 0 to 8 that represent each day's work hours. A pattern string similar to the schedule is given, but some of its digits are replaced by a question mark, ?
. Replace the question marks with digits such that the sum of the scheduled hours is exactly the hours that must be worked in a week.
Input:
- work_hours: Total hours that must be worked in the week.
- day_hours: Maximum hours that may be worked in a day.
- pattern: The partially completed schedule (string of length 7).
Output:
Return all possible valid schedules as a list of strings, sorted lexicographically ascending.
Example:
Input:
pattern = "08??840"
work_hours = 24
day_hours = 4
Output:
[
"0844840",
"0843840",
"0824840",
"0831840",
"0841840"
]
Explanation:
- There are two days on which they must work
2 + 20 = 4
more hours for the week. - The possible schedules are listed in lexicographical order.
Function Description:
Function Name: findSchedules
Parameters:
work_hours
(int): The total hours that must be worked in the week.day_hours
(int): The maximum hours that may be worked in a day.pattern
(str): The partially completed schedule (string of length 7).
Returns:
- A list of strings (
string arr[]
) representing all possible valid schedules, sorted in lexicographical order.
Constraints:
- 1≤work_hours≤561 \leq \text{work\_hours} \leq 56
- 1≤day_hours≤81 \leq \text{day\_hours} \leq 8
- ∣pattern∣=7|\text{pattern}| = 7
- Each character of
pattern
∈ {0, 1, ..., 8, ?}. - There is at least one correct schedule.
Problem: Approximate Matching
Task:
Given three strings, text
, prefixString
, and suffixString
, find:
- prefixScore: The length of the longest substring of
text
matching the end ofprefixString
. - suffixScore: The length of the longest substring of
text
matching the beginning ofsuffixString
.
Scoring:
- Sum the lengths of the two strings to get the textScore.
- The substring of
text
that begins with the matching prefix and ends with the matching suffix and has the highesttextScore
is the correct value to return. - If there are other substrings with equal
textScore
, return the lexicographically lowest substring.
Example:
Input:
text = "engine"
prefixString = "raven"
suffixString = "ginkgo"
Output:
prefixScore = 2
(matches "en" from "raven")suffixScore = 3
(matches "gin" from "ginkgo")textScore = prefixScore + suffixScore = 2 + 3 = 5
- The substring of
text
with the highesttextScore
is"engin"
.
Additional Example:
Input:
text = "banana"
prefixString = "bana"
suffixString = "nana"
Output:
prefixScore = 4
(matches "bana")suffixScore = 4
(matches "nana")textScore = 4 + 4 = 8
- The substring of
text
with the highesttextScore
is"banana"
.
Notes:
- If
prefixString
andsuffixString
overlap, return only the substring oftext
, notprefixString + suffixString
.
Function Description:
Function Name: calculateScore
Parameters:
text
(str): The text to compare.prefixString
(str): The prefix to match.suffixString
(str): The suffix to match.
Returns:
- The longest substring of
text
that begins with an ending substring ofprefixString
and ends with a beginning substring ofsuffixString
.
Constraints:
- 1≤∣text∣,∣prefixString∣,∣suffixString∣≤501 \leq |text|, |prefixString|, |suffixString| \leq 50
- It is guaranteed that there is a substring of
text
that matches at least one of the following:- One or more characters at the end of
prefixString
. - One or more characters at the beginning of
suffixString
.
- One or more characters at the end of
- Strings contain only lowercase English alphabetic letters (
a-z
).
我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.