[Snowflake] OA 2025 start – 3 Mar (generic)

1. Minimum Total Weight

You have n chocolates with weights given in an array weights[n], where weights[i] represents the weight of the ith chocolate. Each day, you can pick one chocolate, consume half of its weight (calculated as floor(weights[i] / 2)) and keep the remaining portion. Calculate the minimum possible total weight of the chocolates after d days. Note that you can eat from the same chocolate multiple times.

Example:

weights = [30, 20, 25]
d = 4
DayWeight of the chocolate pickedWeight eatenRemaining weightResult
1201010[30,10,25]
2251213[30,10,13]
3301515[15,10,13]
41578[8,10,13]

The total weight of chocolates on day 4 is 8 + 10 + 13 = 31, which is the minimum possible weight after 4 days.

Function Description

Complete the function findMinWeight in the editor below.

def findMinWeight(weights: List[int], d: int) -> int:

Parameters:

  • weights[n]: An array of integers representing weights of chocolates, indexed 0 to n-1
  • d: An integer representing the number of days

Returns:

  • int: The minimum total weight of chocolates after d days.

Constraints

  • 1 ≤ n ≤ 10⁵
  • 1 ≤ weights[i] ≤ 10⁴ (where 0 ≤ i < n)
  • 1 ≤ d ≤ 2×10⁶

2. Vowel Substring

Given a string composed of lowercase letters within the ASCII range 'a'-'z', determine the number of substrings that consist solely of vowels, where each vowel appears at least once. The vowels are ['a', 'e', 'i', 'o', 'u']. A substring is defined as a contiguous sequence of characters within the string.

Example

s = 'aeioaexaaeiou'

There is a substring to the left that is made of vowels, 'aeioae', which is followed by an 'x'. Since 'x' is not a vowel, it cannot be included in the substring, and this substring does not contain all vowels. It is not a qualifying substring.

Moving to the right, there are four substrings that do qualify:

  • 'aaeiou'
  • 'aaeio'
  • 'aeoiou'
  • 'aeiou'

Function Descriptio

Complete the function vowelSubstring in the editor with the following parameter(s):

def vowelSubstring(s: str) -> int:

Returns

  • int: The number of substrings that consist of vowels only ('a', 'e', 'i', 'o', 'u') where every vowel appears at least once

Constraints

  • 1 ≤ size_of(s) ≤ 10⁵
  • s[i] is in the range ASCII['a'-'z'] (where 0 ≤ i < size_of(s))

  1. Maximum Order Volume

During the day, a supermarket will receive calls from customers who want to place orders. The supermarket manager knows in advance the number of calls that will be attempted, the start time, duration, and order volume for each call. Only one call can be in progress at any one time, and if a call is not answered, the caller will not call back. The manager must choose which calls to service in order to maximize order volume. Determine the maximum order volume.

Example

start = [10, 5, 15, 18, 30]
duration = [30, 12, 20, 35, 35]
volume = [50, 51, 20, 25, 10]

The above data as a table.

CallerStart timeDurationOrder volume
1103050
251251
3152020
4183525
5303510

The first call will start at time = 10, and last until time = 40.
The second call will start at time = 5, and last until time = 17.
The third call will start at time = 15, and last until time = 35.
The fourth call will start at time = 18, and last until time = 53.
The fifth call will start at time = 30, and last until time = 65.

The first call completely overlaps the second and third calls, and partially overlaps the fourth and fifth calls. Choosing calls that do not overlap, and answering the 2nd and 4th calls leads to the maximum total order volume of 51 + 25 = 76.

我们长期稳定承接各大科技公司如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.

Leave a Reply

Your email address will not be published. Required fields are marked *