The Meta RS OA wasn't too hard. I'd previously studied from an article that turned out to basically be the exact same questions.
Q1: You need to find the index computed from rating divided by prices. If two entries tie, keep the one with the smaller index. When comparing, you don't need to compute the actual decimal — just cross-multiply to compare the two fractions directly.
Q2: You need to complete a given number of round trips (missions). Both a2b and b2a are sorted in ascending order. So you just move forward from the current time, watching both lists, until you find the first entry in a2b or b2a that isn't earlier than the current time, then update the current time and move on to the next trip.
Q3: Execute the instructions in order and see what the 2D array turns into — just follow the instructions step by step. Swapping rows/columns and reversing a row or column are all simple, not much to explain there. For the 90-degree rotation, just transpose rows and columns and then reverse the rows.
Q4: Count how many pairs of i and j let f[i] concatenated with f[j] equal the access code exactly. First record how many times each string in the array appears, then split the access code at every possible point — treat the front part as f[i] and the back part as f[j], look up how many times each occurs, multiply those counts together, and add that to the answer.
Discussion
Loading comments…