3798. Largest Even Number Easy

@problem@discussion
#String



1/**
2 * [3798] Largest Even Number
3 *
4 * You are given a string s consisting only of the characters '1' and '2'.
5 * You may delete any number of characters from s without changing the order of the remaining characters.
6 * Return the largest possible resultant string that represents an even integer. If there is no such string, return the empty string "".
7 *  
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">s = "1112"</span>
11 * Output: <span class="example-io">"1112"</span>
12 * Explanation:
13 * The string already represents the largest possible even number, so no deletions are needed.
14 * </div>
15 * <strong class="example">Example 2:
16 * <div class="example-block">
17 * Input: <span class="example-io">s = "221"</span>
18 * Output: <span class="example-io">"22"</span>
19 * Explanation:
20 * Deleting '1' results in the largest possible even number which is equal to 22.
21 * </div>
22 * <strong class="example">Example 3:
23 * <div class="example-block">
24 * Input: <span class="example-io">s = "1"</span>
25 * Output: <span class="example-io">""</span>
26 * Explanation:
27 * There is no way to get an even number.
28 * </div>
29 *  
30 * Constraints:
31 * 
32 * 	1 <= s.length <= 100
33 * 	s consists only of the characters '1' and '2'.
34 * 
35 */
36pub struct Solution {}
37
38// problem: https://leetcode.com/problems/largest-even-number/
39// discuss: https://leetcode.com/problems/largest-even-number/discuss/?currentPage=1&orderBy=most_votes&query=
40
41// submission codes start here
42
43impl Solution {
44    pub fn largest_even(s: String) -> String {
45        String::new()
46    }
47}
48
49// submission codes end
50
51#[cfg(test)]
52mod tests {
53    use super::*;
54
55    #[test]
56    fn test_3798() {
57    }
58}
59

Back
© 2026 bowen.ge All Rights Reserved.