<p>You are given a string <code>num</code> consisting of digits only.</p>

<p>Return <em>the <strong>largest palindromic</strong> integer (in the form of a string) that can be formed using digits taken from </em><code>num</code>. It should not contain <strong>leading zeroes</strong>.</p>

<p><strong>Notes:</strong></p>

<ul>
	<li>You do <strong>not</strong> need to use all the digits of <code>num</code>, but you must use <strong>at least</strong> one digit.</li>
	<li>The digits can be reordered.</li>
</ul>

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

<pre>
<strong>Input:</strong> num = &quot;444947137&quot;
<strong>Output:</strong> &quot;7449447&quot;
<strong>Explanation:</strong> 
Use the digits &quot;4449477&quot; from &quot;<u><strong>44494</strong></u><u><strong>7</strong></u>13<u><strong>7</strong></u>&quot; to form the palindromic integer &quot;7449447&quot;.
It can be shown that &quot;7449447&quot; is the largest palindromic integer that can be formed.
</pre>

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

<pre>
<strong>Input:</strong> num = &quot;00009&quot;
<strong>Output:</strong> &quot;9&quot;
<strong>Explanation:</strong> 
It can be shown that &quot;9&quot; is the largest palindromic integer that can be formed.
Note that the integer returned should not contain leading zeroes.
</pre>

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

<ul>
	<li><code>1 &lt;= num.length &lt;= 10<sup>5</sup></code></li>
	<li><code>num</code> consists of digits.</li>
</ul>

class Solution:
    def largestPalindromic(self, num: str) -> str:
        sys.set_int_max_str_digits(100000)
        list_to_be_num = []

        for each in num:
            list_to_be_num.append(int(each))
        num = sorted(list_to_be_num, reverse=True)
        print(num)

        hashmap_ones = {}
        hashmap_twos = {}
        for each in num:
            if each in hashmap_ones: 
                hashmap_ones[each] += 1
                if hashmap_ones[each] == 2:
                    hashmap_ones[each] = 0
                    if each in hashmap_twos: 
                        hashmap_twos[each] += 1 
                    if each not in hashmap_twos: 
                        hashmap_twos[each] = 1
            if each not in hashmap_ones:
                hashmap_ones[each] = 1

        print(hashmap_ones)
        print(hashmap_twos)

        twos_string = ""
        twos_reversed = ""

        for each in hashmap_twos:
            twos_string += hashmap_twos[each]*str(each)

        twos_integer = 0
        if twos_string != "":
            twos_integer = int(twos_string)

        if twos_integer == 0:
            twos_string = ""

        j = len(twos_string) - 1 
        while j>=0:
            twos_reversed += twos_string[j]
            j -= 1

        print(twos_string)
        print(twos_reversed)

        for each in hashmap_ones:
            if hashmap_ones[each] != 0:
                twos_string += str(each)
                break

        string_to_return = twos_string + twos_reversed

        if string_to_return == "":
            return "0"

        return string_to_return 

19700