3707. Equal Score Substrings Easy
1/**
2 * [3707] Equal Score Substrings
3 *
4 * You are given a string s consisting of lowercase English letters.
5 * The score of a string is the sum of the positions of its characters in the alphabet, where 'a' = 1, 'b' = 2, ..., 'z' = 26.
6 * Determine whether there exists an index i such that the string can be split into two non-empty <span data-keyword="substring-nonempty">substrings</span> s[0..i] and s[(i + 1)..(n - 1)] that have equal scores.
7 * Return true if such a split exists, otherwise return false.
8 *
9 * <strong class="example">Example 1:
10 * <div class="example-block">
11 * Input: <span class="example-io">s = "adcb"</span>
12 * Output: <span class="example-io">true</span>
13 * Explanation:
14 * Split at index i = 1:
15 *
16 * Left substring = s[0..1] = "ad" with score = 1 + 4 = 5
17 * Right substring = s[2..3] = "cb" with score = 3 + 2 = 5
18 *
19 * Both substrings have equal scores, so the output is true.
20 * </div>
21 * <strong class="example">Example 2:
22 * <div class="example-block">
23 * Input: <span class="example-io">s = "bace"</span>
24 * Output: <span class="example-io">false</span>
25 * Explanation:
26 * No split produces equal scores, so the output is false.
27 * </div>
28 *
29 * Constraints:
30 *
31 * 2 <= s.length <= 100
32 * s consists of lowercase English letters.
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/equal-score-substrings/
38// discuss: https://leetcode.com/problems/equal-score-substrings/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn score_balance(s: String) -> bool {
44 false
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_3707() {
56 }
57}
58Back
© 2026 bowen.ge All Rights Reserved.