Solve 944. Delete Columns to Make Sorted

This commit is contained in:
Kiril Kovachev 2024-03-08 21:05:02 +00:00
parent 1d06cbd973
commit 4919cb9540

View File

@ -0,0 +1,22 @@
impl Solution {
pub fn min_deletion_size(strs: Vec<String>) -> i32 {
let string_length = strs[0].len();
let num_strs = strs.len();
let mut count = 0;
for i in 0..string_length {
let mut current = '\0';
for j in 0..num_strs {
let c = strs[j].chars().nth(i).unwrap();
if c < current {
count += 1;
break;
} else {
current = c;
}
}
}
count
}
}