20250108 finished.

This commit is contained in:
jackfiled 2025-01-08 14:01:44 +08:00
parent 99aaf987df
commit 3226a020c5
2 changed files with 47 additions and 0 deletions

View File

@ -418,3 +418,5 @@ mod p2241_design_an_atm_machine;
mod p2274_maximum_consecutive_floors_without_special_floors;
mod p3019_number_of_changing_keys;
mod p2264_largest_3_same_digit_number_in_string;

View File

@ -0,0 +1,45 @@
/**
* [2264] Largest 3-Same-Digit Number in String
*/
pub struct Solution {}
// submission codes start here
const NUMBERS: [&str; 10] = [
"999", "888", "777", "666", "555", "444", "333", "222", "111", "000",
];
impl Solution {
pub fn largest_good_integer(num: String) -> String {
for n in NUMBERS {
if num.contains(n) {
return n.to_owned();
}
}
"".to_owned()
}
}
// submission codes end
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_2264() {
assert_eq!(
"777".to_owned(),
Solution::largest_good_integer("6777133339".to_owned())
);
assert_eq!(
"000".to_owned(),
Solution::largest_good_integer("2300019".to_owned())
);
assert_eq!(
"".to_owned(),
Solution::largest_good_integer("42352338".to_owned())
);
}
}