Code Question 1: Regex Generator Prototype
Problem Statement:
Amazon developers are building a prototype for a regex generator. The goal is to find the longest regex that matches two given strings x
and y
but does not match a third string z
. If no such regex exists, return -1
. If multiple regexes exist, return the lexicographically smallest one.
A regex is valid if:
- It consists of uppercase English letters,
[
, and]
. - Characters inside square brackets
[ ]
do not repeat. - Square brackets must contain at least one character and be balanced.
Function Signature:
def findLongestRegex(x: str, y: str, z: str) -> str:
pass
Input:
x
(string): A string to match.y
(string): A string to match.z
(string): A string not to match.
Output:
string
: The longest lexicographically smallest regex matchingx
andy
but notz
, or-1
if no such regex exists.
Example Input/Output:
Input:
x = "AB"
y = "BD"
z = "CD"
Output:
"[ABCDEFGHJKLMNOPQRSTUVWXYZ][ABCDEFGHJKLMNOPQRSTUVWXYZ]"
Explanation:
The regex matches x
and y
but not z
. It is the longest valid regex that satisfies the criteria.
Code Question 2: Time-Series Data Dependency
Problem Statement:
Data analysts at Amazon are analyzing time-series data. The data of the n
th item is dependent on the data of some x
th day if there exists a positive integer k
such that:floor(n / k) = x
.
Given an integer n
, find the sum of all the days' numbers on which the data of the x
th (0 ≤ x ≤ n) will be dependent.
Function Signature:
def sumDependentDays(n: int) -> int:
pass
Input:
n
(integer): The given item number.
Output:
integer
: The sum of all the dependent days' numbers.
Example Input/Output:
Input:
n = 10
Output:
18
Explanation:
For n = 10
, the dependencies are calculated for each x
(from 1 to 10). Summing up the day numbers results in 18
.
我们长期稳定承接各大科技公司如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.