aboutsummaryrefslogtreecommitdiff
path: root/other/delete_col_sorted.rs
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-03-10 00:36:13 -0600
committerJack Sangdahl <[email protected]>2025-03-10 00:36:13 -0600
commit7c60dee83b436e8e8a667bf9f191beced8de4fc3 (patch)
treeeb7a24ee2067f92245c57bb118e85a1baf15df50 /other/delete_col_sorted.rs
parent5d7cdc215e4ba1ec4cbb24c084cccb5e5e641468 (diff)
downloadleetcode-7c60dee83b436e8e8a667bf9f191beced8de4fc3.tar.gz
leetcode-7c60dee83b436e8e8a667bf9f191beced8de4fc3.zip
chore: move cpp and rust code to directory
Diffstat (limited to 'other/delete_col_sorted.rs')
-rw-r--r--other/delete_col_sorted.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/other/delete_col_sorted.rs b/other/delete_col_sorted.rs
new file mode 100644
index 0000000..1b7d24a
--- /dev/null
+++ b/other/delete_col_sorted.rs
@@ -0,0 +1,25 @@
+struct Solution;
+
+impl Solution {
+ pub fn min_deletion_size(strs: Vec<String>) -> i32 {
+ let mut ans = 0;
+ let mut new_strs: Vec<Vec<char>> = Vec::new();
+ for i in 0..strs.len() {
+ new_strs.push(strs[i].chars().collect::<Vec<char>>());
+ }
+ for i in 0..new_strs[0].len() {
+ for j in 1..new_strs.len() {
+ if new_strs[j - 1][i] > new_strs[j][i] {
+ ans += 1;
+ break
+ }
+ }
+ }
+ ans
+ }
+}
+
+fn main() {
+ let strs = vec![String::from("cba"), String::from("daf"), String::from("ghi")];
+ print!("{}", Solution::min_deletion_size(strs));
+}