[Citadel] OA 2025 Start – 22 Feb (Generic)

FizzBuzz

    Given a number n, for each integer i in the range from 1 to n inclusive, print one value per line as follows:

    • If i is a multiple of both 3 and 5, print FizzBuzz.
    • If i is a multiple of 3 (but not 5), print Fizz.
    • If i is a multiple of 5 (but not 3), print Buzz.
    • If i is not a multiple of 3 or 5, print the value of i.

    Function Description

    Complete the function fizzBuzz in the editor below.

    fizzBuzz has the following parameter(s):
    int n: upper limit of values to test (inclusive)
    Returns: NONE
    Prints:
    The function must print the appropriate response for each value i in the set {1, 2, ..., n} in ascending order, each on a separate line.

    Sample Output

    1
    2
    Fizz
    4
    Buzz
    Fizz
    7
    8
    Fizz
    Buzz
    11
    Fizz
    13
    14
    FizzBuzz

    Explanation

    The numbers 3, 6, 9, and 12 are multiples of 3 (but not 5), so print Fizz on those lines.

    The numbers 5 and 10 are multiples of 5 (but not 3), so print Buzz on those lines.

    The number 15 is a multiple of both 3 and 5, so print FizzBuzz on that line.

    None of the other values is a multiple of either 3 or 5, so print the value of i on those lines.


    Question 2

      A data processing pipeline consists of n services connected in a series where the output of the iᵗʰ service serves as the input to the (i+1)ᵗʰ service. However, the processing units have varying latencies, and the throughput of the iᵗʰ unit is represented by the array throughput[i] in messages per minute. The first service receives input through an API, and the nᵗʰ service produces the final output.

      Each service can be scaled up independently, with the cost of scaling up the iᵗʰ service one unit equal to scaling_cost[i]. After scaling up a service x times, it can process throughput[i] * (1 + x) messages per minute.

      Given the arrays throughput and scaling_cost, both of size n, and an integer budget representing the budget available, determine the optimal scaling configuration for the services such that the throughput generated by the nᵗʰ service is maximized.

      Example

      For instance, throughput = [4, 2, 7], scaling_cost = [3, 5, 6], and budget = 32.

      To maximize the throughput of the final service, an optimal solution is:

      Service IndexScale FromScale ToTimes ScaledCost per Scaling
      041223
      121045
      271416

      When these units are applied in series, they generate a throughput of 10 units, the maximum possible throughput given the budget. Hence the answer is 10.

      Function Description

      Complete the function getMaximumThroughput in the editor below.

      getMaximumThroughput has the following parameters:
      int throughput[n]: the throughput generated by each of the n services
      int scaling_cost[n]: the cost of scaling up a service one time
      int budget: the available money

      Returns
      long int: the maximum value of the throughput generated at the end of the composite service after scaling within the budget

      Constraints

      • 1 ≤ n ≤ 10⁵
      • 1 ≤ throughput[i] ≤ 10⁷
      • 1 ≤ scaling_cost[i] ≤ 200
      • 1 ≤ budget ≤ 10⁹
      • It is guaranteed that the answer, i.e., the maximum throughput value at the end of the n services is ≤ 10⁹


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