Total Duration: 120 min
Number of Questions: 5
Each question has a time limit, unused time can be accumulated for later questions. You cannot go back to previous questions.
Question One:
5-minute time limit
Starting letter is “A”
input: “BZA” uppercase English letters
output: 4
explanation: A → B = 1, B → Z = 2, Z->A = 1. TOTAL: 1+2+1=4
There seems to be a similar original question, but I forgot. The difficulty is not high, mainly due to the tight time constraint.
Question Two:
20-minute time limit
string contains only | and *
input: string = "|**||", startIndex = [1, 1], endIndex[5, 6]
output: [2, 3]
explanation: Index starts from 1. In the range [1, 5], the number of asterisks () included
Approach:
Record the indexes of all ‘|’ and the number of stars before this index, using binary search and presum.
Result:
Normal test cases cause TLE, it feels like DP optimization is needed. The difficulty seems somewhat hard.
Question Three:
25 minutes
Subarray inversion
Find all subarrays of length three. Can only remove digits, cannot change the order.
input: [5, 4, 2, 1]
output: [5, 4, 2], [5, 4, 1], [5, 2, 1], [4, 2, 1], return the integer 4
Approach:
Backtrack with memorization.
Result:
Couldn’t optimize with DP, about half of the test cases cause TLE.
Question Four:
30 minutes
Convert Roman numerals to decimal, return sorted integers
1: I, 10: X, 50: L.
input: [“XI”, “XL”, “LX”]
output: [6, 40, 60]
Couldn’t complete it.
Question Five:
1 hour
Difficulty too high, not attempted, related to linked lists and DP.
Overall Impression:
The difficulty of the completely exceeds my level, writing up to a certain point makes me feel overwhelmed. Hope if anyone finds the original questions, they can share the question numbers for everyone’s benefit!