1363. Largest Multiple of Three Hard
1/**
2 * [1363] Largest Multiple of Three
3 *
4 * Given an array of digits digits, return the largest multiple of three that can be formed by concatenating some of the given digits in any order. If there is no answer return an empty string.
5 * Since the answer may not fit in an integer data type, return the answer as a string. Note that the returning answer must not contain unnecessary leading zeros.
6 *
7 * Example 1:
8 *
9 * Input: digits = [8,1,9]
10 * Output: "981"
11 *
12 * Example 2:
13 *
14 * Input: digits = [8,6,7,1,0]
15 * Output: "8760"
16 *
17 * Example 3:
18 *
19 * Input: digits = [1]
20 * Output: ""
21 *
22 *
23 * Constraints:
24 *
25 * 1 <= digits.length <= 10^4
26 * 0 <= digits[i] <= 9
27 *
28 */
29pub struct Solution {}
30
31// problem: https://leetcode.com/problems/largest-multiple-of-three/
32// discuss: https://leetcode.com/problems/largest-multiple-of-three/discuss/?currentPage=1&orderBy=most_votes&query=
33
34// submission codes start here
35
36impl Solution {
37 pub fn largest_multiple_of_three(digits: Vec<i32>) -> String {
38 String::new()
39 }
40}
41
42// submission codes end
43
44#[cfg(test)]
45mod tests {
46 use super::*;
47
48 #[test]
49 fn test_1363() {
50 }
51}
52
Back
© 2025 bowen.ge All Rights Reserved.