TheRealSamuel/LeetCodeProblem
0572
1{2 "id": 2475,3 "name": "largest_palindromic_number",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/largest-palindromic-number/",6 "date": "1660435200000",7 "task_description": "You are given a string `num` consisting of digits only. Return _the **largest palindromic** integer (in the form of a string) that can be formed using digits taken from _`num`. It should not contain **leading zeroes**. **Notes:** You do **not** need to use all the digits of `num`, but you must use **at least** one digit. The digits can be reordered. **Example 1:** ``` **Input:** num = \"444947137\" **Output:** \"7449447\" **Explanation:** Use the digits \"4449477\" from \"**44494****7**13**7**\" to form the palindromic integer \"7449447\". It can be shown that \"7449447\" is the largest palindromic integer that can be formed. ``` **Example 2:** ``` **Input:** num = \"00009\" **Output:** \"9\" **Explanation:** It can be shown that \"9\" is the largest palindromic integer that can be formed. Note that the integer returned should not contain leading zeroes. ``` **Constraints:** `1 <= num.length <= 105` `num` consists of digits.",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "num = \"444947137\"",12 "output": "\"7449447\" "13 },14 {15 "label": "Example 2",16 "input": "num = \"00009\"",17 "output": "\"9\" "18 }19 ],20 "private_test_cases": [21 {22 "input": "4574357",23 "output": "7543457"24 },25 {26 "input": "323771360305980",27 "output": "733090337"28 },29 {30 "input": "915977436646661402578806504359626452933532890394320262788748102836284924152437266070747858033901879",31 "output": "99998888877777666666555544444333332222221100000900000112222223333344444555566666677777888889999"32 },33 {34 "input": "8288073188005753773764289343236297261209139278936329",35 "output": "9998887776654333322221008001222233334566777888999"36 },37 {38 "input": "76460896679381678729518210215426903546870637252450074473722681197470990848740583",39 "output": "999888877777766665554444332222111000090000111222233444455566667777778888999"40 },41 {42 "input": "640561031312180076174196658564620",43 "output": "87666543211100900111234566678"44 },45 {46 "input": "38286509445513",47 "output": "854393458"48 },49 {50 "input": "18796610610152728699956907327526994501042085030356183882245317618431649159",51 "output": "999988877666655554433322211111000090000111112223334455556666778889999"52 },53 {54 "input": "9249031911327257978608320605506328216552099502171897527492664374199557948938161464101809914867350",55 "output": "99999998888777766665555544443332222211111100000700000111111222223334444555556666777788889999999"56 },57 {58 "input": "958186096215117931164019189995544089530747635649857600585949137997186954099326185909122",59 "output": "9999999998888777666655555444332211111100005000011111122334445555566667778888999999999"60 }61 ],62 "haskell_template": "largestPalindromic :: String -> String\nlargestPalindromic num ",63 "ocaml_template": "let largestPalindromic (num: string) : string = ",64 "scala_template": "def largestPalindromic(num: String): String = { \n \n}",65 "java_template": "public static String largestPalindromic(String num) {\n\n}",66 "python_template": "class Solution(object):\n def largestPalindromic(self, num):\n \"\"\"\n :type num: str\n :rtype: str\n \"\"\"\n "67}