> 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/1163-last-substring-in-lexicographical-order.md).

# 1163. Last Substring in Lexicographical Order

<https://leetcode.com/problems/last-substring-in-lexicographical-order>

## Description

Given a string `s`, return *the last substring of* `s` *in lexicographical order*.

**Example 1:**

```
**Input:** s = "abab"
**Output:** "bab"
**Explanation:** The substrings are ["a", "ab", "aba", "abab", "b", "ba", "bab"]. The lexicographically maximum substring is "bab".
```

**Example 2:**

```
**Input:** s = "leetcode"
**Output:** "tcode"
```

**Constraints:**

* `1 <= s.length <= 4 * 105`
* `s` contains only lowercase English letters.

## ac

```java
```
