Solve the following coding problems.
Given:
buses[]
of bus departure times (minutes since 00:00).
arrivals[]
of passenger arrival times (minutes since 00:00).
For each passenger, return the earliest bus departure time that is >= their arrival time, or -1 if no such bus exists.
Constraints:
1 <= len(buses), len(arrivals) <= 2e5
You are given a list of passengers. Each passenger has:
priority
(smaller number = higher priority, e.g. 0 is best)
checkInTime
(integer)
name
(string)
Output the boarding order under these rules:
checkInTime
boards first.
Follow-up: If passengers arrive as a stream, how would you produce the next passenger to board efficiently?
A file/stream contains multiple passwords encoded as (index, char) pairs in order of appearance. A password is defined by indices 0..L-1 appearing exactly once each, where L is the password length.
Rules:
index
that has already appeared in the
current
password indicates the start of the
next
password (i.e., the pair you just read belongs to the next password).
L of the first decoded password
.
Return all decoded passwords in order.
Given:
expr
containing integers,
+
and
-
, parentheses
(
)
, optional whitespace, and variable names consisting of letters.
{x: 3, y: 10}
), guaranteed to include any variables present.
Compute and return the integer result.
Note: You may not assume there are spaces between tokens.