ARTS #206 | 暑假结束 小朋友暑假结束,前几天自己一个人坐飞机回到了厦门,本来是试探性地问她敢不敢自己坐飞机回来,没想到真的敢! Algorithm 本周选择的算法题是:Unique Paths。 impl Solution { pub fn unique_paths(m: i32, n: i32) -> i32 { let mut current = vec。 use std::collections::HashMap; impl Solution { pub fn soup_servings(n: i32)...
ARTS #203 | AI 线描上色真好玩 AI 线描上色真好玩~ Algorithm 本周选择的算法题是:Knight Probability in Chessboard。 impl Solution { pub fn knight_probability(n: i32, k: i32, row: i32, column: i32) -> f64 { let mut dp = vec!...
ARTS #202 | 1111天 扇贝打卡 1111 天了,继续加油~ Algorithm 本周选择的算法题是:Find All K-Distant Indices in an Array。 impl Solution { pub fn find_k_distant_indices(nums: Vec<i32>, key: i32, k: i32) -> Vec<i32>...
ARTS #201 | 小蜜蜂 端午在海边画了只小蜜蜂 Algorithm 本周选择的算法题是:Number of Substrings With Only 1s。 impl Solution { pub fn num_sub(s: String) -> i32 { const MODULO: i64 = 10_i64.pow(9) + 7; let (mut...
ARTS #200 | 参加展览 带着自己的作品参加展览,一路上很兴奋~ Algorithm 本周选择的算法题是:Snapshot Array。 struct SnapshotArray { snapshots: Vec<Vec<(i32, i32)>>, snap_id: i32, } /** * `&self` means the method ta...
ARTS #199 | 家长开放日 第一次参加幼儿园的家长开放日活动,老师带着做早操,活力满满~ Algorithm 本周选择的算法题是:Destroying Asteroids。 impl Solution { pub fn asteroids_destroyed(mass: i32, mut asteroids: Vec<i32>) -> bool { aster...
ARTS #198 | 龙船花 Algorithm 本周选择的算法题是:Maximize Score After N Operations。 impl Solution { pub fn max_score(nums: Vec<i32>) -> i32 { let mut dp = vec![-1; 1 << nums.len()]; Self:...
ARTS #197 | 看了个球 Algorithm 本周选择的算法题是:Number of Strings That Appear as Substrings in Word。 impl Solution { pub fn num_of_strings(patterns: Vec<String>, word: String) -> i32 { let mut count =...