[Millennium] OA 2025 Start – 12 Feb (Generic)

SQL: Financial Asset Portfolio Evaluation

A financial firm manages portfolios for clients, comprising various assets like bonds, stocks, and commodities. They wish to evaluate the return on investment (ROI) for each asset within a client’s portfolio over a given year.

The statistic required is the annual ROI for each asset, given the initial investment amount, total returns for the year, and any additional investments made during the year.

The result should have the following columns:
name | asset_name | asset_type | annual_roi

  • name - name of the client.
  • asset_name - name of the bond, stock, or commodity.
  • asset_type - type of the asset.
  • annual_roi - the annual return on investment for the asset as a percentage, calculated as
    (total returns + additional investments - initial investment) / initial investment * 100, rounded to two decimal places.

The result should be sorted in ascending order by name, then in ascending order by asset_name.

Note:

  • Only assets that have an annual ROI greater than 5% should be included in the result.
  • Include trailing zeros after the decimal in annual_roi, e.g., 8.80.

REST API: Transaction Statements for Users

Given a transaction type and location, retrieve the total amount of transactions of the specified type at the specified location using a REST API. Group the information by user and sort it in ascending order by numerical user ID.

To access the transaction logs, make an HTTP GET request to:

https://jommock.hackerrank.com/api/transactions/search?txnType=<transactionType>&page=<pageNumber>

Here, <transactionType> is either "debit" or "credit" and <pageNumber> is an integer representing the results page.

For instance, a GET request to:

https://jommock.hackerrank.com/api/transactions/search?txnType=debit&page=2

retrieves the second page of transactions that are of the "debit" type. Pages start at 1, so the first page is accessed with page=1.

The response to a request is a JSON object with the following structure:

  • page: The current page of the result.
  • per_page: The maximum number of transaction records included per page.
  • total: The total number of transaction records available on all pages of the result.
  • total_pages: The total number of pages with results.
  • data: An array of objects containing transaction records on the requested page.

Each transaction record has the following schema:

  • id: The unique ID of the record.
  • timestamp: The timestamp when the record was generated (in UTC milliseconds).
  • userId: The integer ID of the user who performed the transaction.
  • userName: The user name of the user who performed the transaction.
  • txnType: The transaction type of the transaction, either "debit" or "credit".
  • amount: The transaction amount stored as a string with the currency structure and prefixed with the $ sign, e.g., "$2,273.95", "$23.52", "$17".
  • location: The object containing the location description of the transaction.
  • ip: The IP address of the device which was used to perform the transaction.

Generator Context

Implement a context manager class called sequence_generator that takes in two integers, start and step. It exposes a method called generate, a Python generator that yields an infinite sequence of numbers starting from start and adding step each iteration.

Example

with sequence_generator(3, 5) as gen:  
    for _ in range(3):  
        print(next(gen), end=" ")  

There are 3 requests to sequence_generator, and the values printed are 3, 8, and 13, so "3 8 13" is printed.

Function Description

Complete the class sequence_generator in the editor below. It should be a context manager class and should expose generate.

sequence_generator's __init__() method has the following parameter(s):

  • int start: the start value
  • int step: the increment at each call

Constraints

  • 1 ≤ start, step ≤ 100
  • 1 ≤ num ≤ 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 *