Class Solution
java.lang.Object
g2301_2400.s2384_largest_palindromic_number.Solution
2384 - Largest Palindromic Number.<p>Medium</p>
<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><strong>Example 1:</strong></p>
<p><strong>Input:</strong> num = “444947137”</p>
<p><strong>Output:</strong> “7449447”</p>
<p><strong>Explanation:</strong></p>
<p>Use the digits “4449477” from “<ins> <strong>44494</strong> </ins><ins> <strong>7</strong> </ins>13<ins> <strong>7</strong> </ins>” to form the palindromic integer “7449447”.</p>
<p>It can be shown that “7449447” is the largest palindromic integer that can be formed.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> num = “00009”</p>
<p><strong>Output:</strong> “9”</p>
<p><strong>Explanation:</strong></p>
<p>It can be shown that “9” is the largest palindromic integer that can be formed.</p>
<p>Note that the integer returned should not contain leading zeroes.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= num.length <= 10<sup>5</sup></code></li>
<li><code>num</code> consists of digits.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
largestPalindromic
-