> For the complete documentation index, see [llms.txt](https://jaywin.gitbook.io/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jaywin.gitbook.io/leetcode/solutions/1842-next-palindrome-using-same-digits.md).

# 1842. Next Palindrome Using Same Digits

<https://leetcode.com/problems/next-palindrome-using-same-digits>

## Description

You are given a numeric string `num`, representing a very large **palindrome**.

Return *the **smallest palindrome larger than*** `num` *that can be created by rearranging its digits. If no such palindrome exists, return an empty string* `""`.

A **palindrome** is a number that reads the same backward as forward.

**Example 1:**

```
**Input:** num = "1221"
**Output:** "2112"
**Explanation:** The next palindrome larger than "1221" is "2112".
```

**Example 2:**

```
**Input:** num = "32123"
**Output:** ""
**Explanation:** No palindromes larger than "32123" can be made by rearranging the digits.
```

**Example 3:**

```
**Input:** num = "45544554"
**Output:** "54455445"
**Explanation:** The next palindrome larger than "45544554" is "54455445".
```

**Constraints:**

* `1 <= num.length <= 105`
* `num` is a **palindrome**.

## ac

```java
```
