Mathworks OA 2025 Start – 25 Dec

Problem Statement

There are n jobs that can be executed in parallel on a processor, where the execution time of the i-th job is executionTime[i]. To speed up execution, the following strategy is used:

  • In one operation, a job is chosen, the major job, and is executed for x seconds. All other jobs are executed for y seconds where y < x.
  • A job is complete when it has been executed for at least executionTime[i] seconds, then it exits the pool.

Find the minimum number of operations in which the processor can completely execute all the jobs if run optimally.


Example

Consider n = 5, executionTime = [3, 4, 1, 7, 6], x = 4, and y = 2.

The following strategy is optimal using 1-based indexing:

  • Choose job 4 as the major job and reduce the execution times of job 4 by x = 4 and of other jobs by y = 2.
    Now executionTime = [1, 2, -1, 3, 4]. Job 3 is complete, so it is removed.
  • Choose job 4 again,
    executionTime = [-1, 0, -, -1, 2].
    So, jobs 1, 2, and 4 are now complete.
  • Choose job 5,
    executionTime = [-, -, -, -, -2].
    Job 5 is complete.

It takes 3 operations to execute all the jobs so the answer is 3.


Function Description

Complete the function getMinimumOperations in the editor below.

getMinimumOperations

  • Parameters:
    • int executionTime[n]: the execution times of each job
    • int x: the time for which the major job is executed
    • int y: the time for which all other jobs are executed
  • Returns:
    • int: the minimum number of operations in which the processor can execute all the jobs

Problem Statement

Given a string array that contains n elements, each composed of lowercase English letters, and q queries, each query of the format l-r. For each query, determine how many strings starting from index l and ending at index r have vowels as the first and last character. Vowels are in {a, e, i, o, u}.


Example

strArr = ['aba', 'bcb', 'ece', 'aa', 'e']
queries = ['1-3', '2-5', '2-2']

These strings represent two dash-delimited integers l and r, the start and end indices of the interval, inclusive. Using 1-based indexing in the string array:

  • The interval 1-3 contains two strings that start and end with a vowel: 'aba' and 'ece'.
  • The interval 2-5 also has three.
  • The third interval, from 2-2, the only element in the interval, 'bcb', does not begin and end with a vowel.

The return array for the queries is [2, 3, 0].


Function Description

Complete the hasVowels function in the editor below. It must return an array of integers that represent the result of each query in the order given.

hasVowels

  • Parameters:
    • strArr string[]: an array of n strings
    • query string[]: an array of q strings, each of which describes an interval l-r using integers delimited by a dash
  • Returns:
    • int[]: an array of integers representing the results of the queries

Constraints

  1. 1 ≤ n, q ≤ 10^5
  2. 1 ≤ l ≤ r ≤ n
  3. 1 ≤ size of strArr[i] ≤ 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 *