<p>Given an array of digits <code>digits</code>, return <em>the largest multiple of <strong>three</strong> that can be formed by concatenating some of the given digits in <strong>any order</strong></em>. If there is no answer return an empty string.</p>

<p>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.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> digits = [8,1,9]
<strong>Output:</strong> &quot;981&quot;
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> digits = [8,6,7,1,0]
<strong>Output:</strong> &quot;8760&quot;
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> digits = [1]
<strong>Output:</strong> &quot;&quot;
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= digits.length &lt;= 10<sup>4</sup></code></li>
	<li><code>0 &lt;= digits[i] &lt;= 9</code></li>
</ul>

import numpy as np
import itertools
class Solution:

    def decimalnumber(self,arr_):
        sum_=0
        len_arr=len(arr_)
        for i in range(0,len_arr):
            sum_+=np.power(10,len_arr-1-i)*arr_[i]
        return sum_

    def largestMultipleOfThree(self, digits: list[int]) -> str:
        len_digits=len(digits)

        if len_digits==1 and digits[0] in [3,9]:
            return  digits[0]

        digits=sorted(digits,reverse=True)
        #print(digits)
        digits=np.array(digits)
        sum_digits=np.sum(digits)
        
        if sum_digits==0:
            return "0"

        mod_=np.mod(sum_digits,3)
        if not mod_:
            digits=[str(x) for x in digits]
            return "".join(digits)

        #print(sum_digits)
        #print("mod:{}".format(mod_))

        digits_str=""

        #print(np.cumsum(digits[::-1]))
        Final_Digits=[]
        
        zero_digits=[x for x in digits if x==0 ]
        len_digits_zero=len(zero_digits)
        #print(len_digits_zero)
        len_digits_nonzero=len_digits-len_digits_zero
        
        #print(len_digits_zero)
        #print(len_digits)
            
        digits=digits[:len_digits_nonzero+1]
        #print(digits)
        digits_pos=range(0,len_digits_nonzero)
        #DigitSet=set(digits_pos)
        #print(len_digits)
        for n_ in range(1,len_digits_nonzero):
            #print("n_:{}".format(n_))
            if Final_Digits:
                break
            for array_ in itertools.combinations(digits_pos,len_digits_nonzero-n_):
                #indices=list(DigitSet-set(array_))
                #indices=indices[::-1]
                #print(indices)
                new_number=digits[list(array_)]
                if np.mod(np.sum(new_number),3)==0:
                    #print(indices)
                    #print([str(x_) for x_ in new_number])
                    dec_number=[str(x_) for x_ in new_number]
                    dec_number+=[str(x_) for x_ in zero_digits]
                    return "".join(dec_number)

        
        if len_digits_zero:
            return "0"
        
        return ""
30600