Longest Increasing Subsequence LeetCode solution in Rust
1impl Solution {2pub fn length_of_lis(nums: Vec<i32>) -> i32 {3let mut v: Vec<i32> = vec![*nums.first().unwrap()];4for n in nums.iter() {5if n > v.last().unwrap() {6v.push(*n);7} else {8let pos = v.binary_search(n);9if let Err(pos) = pos {10if v[pos] > *n {11v[pos] = *n;12}13}14}15}16v.len() as i3217}18}