Autonomous Driving Sensor Reliability Analysis
In Tesla's autonomous driving systems, a vast array of sensors constantly monitor the vehicle's surroundings. The reliability of these sensors is paramount for safe and effective operation. As the vehicle traverses a route, different road segments might expose sensors to varying conditions, affecting their performance. It's crucial to quickly assess the weakest link in sensor reliability over any given sub-route to make informed decisions, such as adjusting driving behavior or triggering recalibration.
You are tasked with implementing a system to efficiently manage and query sensor reliability scores along a predefined route. The route is divided into n discrete segments, each with an initial sensor reliability score. You will need to process a series of operations:
index undergoes recalibration, and its reliability score changes to a newValue.[L, R] (inclusive).Your solution should provide fast responses to both update and query operations.
Function Signature:
function processSensorOperations(n: number, initialReliabilities: number[], operations: [string, number, number][]): number[]
n: An integer representing the total number of segments in the route. Segments are indexed from 0 to n-1.initialReliabilities: An array of n integers, where initialReliabilities[i] is the initial reliability score for segment i.operations: An array of operations to perform. Each operation is an array of three elements:
["update", index, newValue]: Update the reliability score of segment index to newValue.["query", L, R]: Query the minimum reliability score within the range of segments [L, R] (inclusive).operations array.L, R, and index are 0-based.[L, R], it is guaranteed that 0 <= L <= R < n.[index, newValue], it is guaranteed that 0 <= index < n.initialReliabilities array will always have n elements.Examples
Example 1
Input:
n = 5, initialReliabilities = [10, 20, 5, 15, 30], operations = [["query", 0, 4], ["update", 2, 12], ["query", 1, 3], ["query", 0, 1]]
Output:
[5, 12, 10]
Note:
Initial: [10, 20, 5, 15, 30]
Example 2
Input:
n = 3, initialReliabilities = [100, 50, 200], operations = [["query", 0, 0], ["update", 0, 40], ["query", 0, 2], ["update", 1, 30], ["query", 1, 1]]
Output:
[100, 40, 30]
Note:
Initial: [100, 50, 200]
Example 3
Input:
n = 1, initialReliabilities = [75], operations = [["query", 0, 0], ["update", 0, 90], ["query", 0, 0]]
Output:
[75, 90]
Note:
Initial: [75]
Constraints
1 <= n <= 10^50 <= initialReliabilities[i] <= 10^9 for all i0 <= newValue <= 10^9 for update operations1 <= operations.length <= 10^50 <= L <= R < n for query operations0 <= index < n for update operationsLoading editor...