daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Mar 19th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fn find_increasing_seq(seq: &[i32]) -> Vec<i32> {
  2.     let mut output = Vec::new();
  3.     if seq.len() < 2 {
  4.         return output;
  5.     }
  6.     output.push(seq[0]);
  7.     for i in 1..seq.len() {
  8.         if seq[i] >= seq[i - 1] {
  9.             output.push(seq[i]);
  10.         } else {
  11.             break;
  12.         }
  13.     }
  14.     output.dedup();
  15.     output
  16. }
  17.  
  18. fn main() {
  19.     let numbers = vec![1, 2, 3, 4, 4, 5, 4, 6];
  20.     println!("{:?}", find_increasing_seq(&numbers));
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top