aboutsummaryrefslogtreecommitdiff
path: root/partition_array_pivot.rs
diff options
context:
space:
mode:
Diffstat (limited to 'partition_array_pivot.rs')
-rw-r--r--partition_array_pivot.rs32
1 files changed, 0 insertions, 32 deletions
diff --git a/partition_array_pivot.rs b/partition_array_pivot.rs
deleted file mode 100644
index 8a126da..0000000
--- a/partition_array_pivot.rs
+++ /dev/null
@@ -1,32 +0,0 @@
-struct Solution;
-
-impl Solution {
- pub fn pivot_array(nums: Vec<i32>, pivot: i32) -> Vec<i32> {
- let mut greater = vec![];
- let mut same = 0;
- let ans = vec![];
- for n in nums {
- if n < pivot {
- ans.push(n);
- } else if n == pivot {
- same += 1;
- } else {
- greater.push(n);
- }
- }
- for _ in 0..same {
- ans.push(pivot);
- }
- for g in greater {
- ans.push(g);
- }
- ans
- }
-}
-
-fn main() {
- let s = Solution;
- let nums = vec![9,12,5,10,14,3,10];
- let pivot = 10;
- print!("{}", s.pivot_array(nums, pivot));
-}