Solve Four Online Assessment Problems
MetaSoftware Engineer · Technical ScreenLast updated
This multi-part question evaluates algorithmic problem-solving across array manipulation, exact fraction comparison, scheduling and simulation with ordered event lists, matrix transformation operations, and string concatenation/counting, exercising skills in data structures, searching, and combinatorial counting.
Complete the following four independent coding tasks. For each task, write a function that returns the requested result.
- Find the best value index
You are given two equal-length integer arrays, ratings and prices, where prices[i] > 0. For each index i, define its value as ratings[i] / prices[i]. Return the index with the largest value. If multiple indices have the same value, return the smallest such index.
Avoid relying on floating-point division for comparisons; compare fractions exactly.
- Schedule round trips
You need to complete missions round trips between two locations, A and B. A round trip consists of one trip from A to B, followed by one trip from B to A.
You are given two sorted arrays:
aToB: times at which you can travel fromAtoBbToA: times at which you can travel fromBtoA
You start at location A at time 0. For each leg, you must choose the earliest available time in the corresponding array that is greater than or equal to your current time. After taking that trip, your current time becomes the chosen time. Return the earliest time after completing all missions round trips. If it is impossible to complete all trips, return -1.
- Execute matrix transformation commands
You are given a 2D matrix and a list of commands. Execute the commands in order and return the final matrix.
The command types are:
swapRows r1 r2: swap rowsr1andr2swapCols c1 c2: swap columnsc1andc2reverseRow r: reverse the elements in rowrreverseCol c: reverse the elements in columncrotate90: rotate the entire matrix 90 degrees clockwise
Use zero-based indices. After a rotation, the matrix dimensions may change.
- Count concatenation pairs matching an access code
You are given an array of strings fragments and a target string accessCode. Count the number of ordered pairs of indices (i, j) such that:
fragments[i] + fragments[j] == accessCode
Duplicate strings in fragments count separately. An index may be used for both i and j if it satisfies the condition. Return the total count.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.