Two Pointer w/ on-the-fly prefix sums. 100%
Intuition\nBecause we can only pick two events, first simply the problem to finding a second event which maximizes the value when added to a prefix sum. \n\n# A
# Intuition\nBecause we can only pick two events, first simply the problem to finding a **second** event which maximizes the value when added to a prefix sum. \n\n# Approach\n- Split events into starts and ends, cloning the value. \n- Sort the vectors.\n- Go left to right on the start list, for each second event cantidate,\n    - Compute the prefix-sum on the fly by maxing until your second pointer passes your first. \n    - Compute total value and update running max.\n\n\n# Complexity\n- Time complexity:\n$O(n \\cdot logn)$\n- Space complexity:\n$O(n)$\n\n# Code\n```rust []\nimpl Solution {\n    pub fn max_two_events(events: Vec<Vec<i32>>) -> i32 {\n        let (mut starts, mut ends): (Vec<(i32,i32)>, Vec<(i32,i32)>) = events.into_iter().map(|event| {\n            //Start\n            ((event[0], event[2]),\n            //End\n             (event[1], event[2]))\n        }).unzip();\n\n        starts.sort();\n        ends.sort();\n\n        let mut first_end_idx = 0;\n        let mut cur_first_max = 0;\n        let mut total_max = 0;\n\n        for (second_start, second_val) in starts {\n            while ends[first_end_idx].0 < second_start {\n                cur_first_max = cur_first_max.max(ends[first_end_idx].1);\n                first_end_idx += 1;\n            }\n\n            total_max = total_max.max(cur_first_max + second_val);\n        }\n\n        total_max\n    }\n}\n```
['Rust']