✅ [Rust] fastest (100%) solution using boolean array (with detailed comments)
This solution employs a simple boolean array to store the upload status that is used to update longest prefix index. It demonstrated 98 ms runtime (100.00%) and
This [**solution**](https://leetcode.com/submissions/detail/814188631/) employs a simple boolean array to store the upload status that is used to update longest prefix index. It demonstrated **98 ms runtime (100.00%)** and used **54.5 MB memory (100.00%)**. Time complexity is linear: **O(N)**. Space complexity is constant: **O(1)**. Detailed comments are provided.\n\n**IF YOU LIKE THIS SOLUTION, PLEASE UPVOTE.**\n```\nstruct LUPrefix \n{\n    prefixes       : Vec<bool>,\n    longest_prefix : i32\n}\n\nimpl LUPrefix \n{\n    fn new(n: i32) -> Self \n    {\n        LUPrefix{ prefixes: vec![false;n as usize +2], longest_prefix: 0 }\n    }\n    \n    fn upload(&mut self, video: i32) \n    {\n        self.prefixes[video as usize] = true;\n    }\n    \n    fn longest(&mut self) -> i32\n    {\n        // on request, update the longest prefix using \n        // the upload status data from the boolean array \n        while self.prefixes[self.longest_prefix as usize + 1]\n        {\n            self.longest_prefix += 1;\n        }\n\n        self.longest_prefix\n    }\n}\n```\n
['Array', 'Rust']