All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g1301_1400.s1363_largest_multiple_of_three.readme.md Maven / Gradle / Ivy

There is a newer version: 1.24
Show newest version
1363\. Largest Multiple of Three

Hard

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.

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.

**Example 1:**

**Input:** digits = [8,1,9]

**Output:** "981"

**Example 2:**

**Input:** digits = [8,6,7,1,0]

**Output:** "8760"

**Example 3:**

**Input:** digits = [1]

**Output:** ""

**Constraints:**

*   1 <= digits.length <= 104
*   `0 <= digits[i] <= 9`




© 2015 - 2024 Weber Informatics LLC | Privacy Policy