2930. Number of Strings Which Can Be Rearranged to Contain Substring Medium
1/**
2 * [2930] Number of Strings Which Can Be Rearranged to Contain Substring
3 *
4 * You are given an integer n.
5 * A string s is called good if it contains only lowercase English characters and it is possible to rearrange the characters of s such that the new string contains "leet" as a substring.
6 * For example:
7 *
8 * The string "lteer" is good because we can rearrange it to form "leetr" .
9 * "letl" is not good because we cannot rearrange it to contain "leet" as a substring.
10 *
11 * Return the total number of good strings of length n.
12 * Since the answer may be large, return it modulo 10^9 + 7.
13 * A substring is a contiguous sequence of characters within a string.
14 * <div class="notranslate" style="all: initial;"> </div>
15 *
16 * <strong class="example">Example 1:
17 *
18 * Input: n = 4
19 * Output: 12
20 * Explanation: The 12 strings which can be rearranged to have "leet" as a substring are: "eelt", "eetl", "elet", "elte", "etel", "etle", "leet", "lete", "ltee", "teel", "tele", and "tlee".
21 *
22 * <strong class="example">Example 2:
23 *
24 * Input: n = 10
25 * Output: 83943898
26 * Explanation: The number of strings with length 10 which can be rearranged to have "leet" as a substring is 526083947580. Hence the answer is 526083947580 % (10^9 + 7) = 83943898.
27 *
28 *
29 * Constraints:
30 *
31 * 1 <= n <= 10^5
32 *
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/number-of-strings-which-can-be-rearranged-to-contain-substring/
37// discuss: https://leetcode.com/problems/number-of-strings-which-can-be-rearranged-to-contain-substring/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42 pub fn string_count(n: i32) -> i32 {
43 0
44 }
45}
46
47// submission codes end
48
49#[cfg(test)]
50mod tests {
51 use super::*;
52
53 #[test]
54 fn test_2930() {
55 }
56}
57
Back
© 2025 bowen.ge All Rights Reserved.