Just a runnable solution
Code\n\nimpl Solution {\n    pub fn num_perms_di_sequence(s: String) -> i32 {\n        let n = s.len();\n        let m = 1_000_000_007;\n        let mut dp = ve
# Code\n```\nimpl Solution {\n    pub fn num_perms_di_sequence(s: String) -> i32 {\n        let n = s.len();\n        let m = 1_000_000_007;\n        let mut dp = vec![vec![0; n + 1]; n + 1];\n        dp[0][0] = 1;\n        for i in 1..=n {\n            for j in 0..=i {\n                if s.chars().nth(i - 1).unwrap() == \'D\' {\n                    for k in j..=i - 1 {\n                        dp[i][j] = dp[i][j] % m + dp[i - 1][k] % m;\n                    }\n                } else if j > 0 {\n                    for k in 0..=j - 1 {\n                        dp[i][j] = dp[i][j] % m + dp[i - 1][k] % m;\n                    }\n                }\n            }\n        }\n        let mut res = 0;\n        for i in 0..=n {\n            res = res % m + dp[n][i] % m;\n        }\n        (res % m) as _\n    }\n}\n```
['Rust']