Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    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:

    • <code>1 <= digits.length <= 10<sup>4</sup></code>

    • 0 &lt;= digits[i] &lt;= 9

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final String largestMultipleOfThree(IntArray digits)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait