/*
* @lc app=leetcode.cn id=1163 lang=typescript
*
* [1163] 按字典序排在最后的子串
*/
// @lc code=start
function lastSubstring(s: string): string {}
// @lc code=end
function lastSubstring(s: string): string {
const n = s.length
let res = ''
for (let i = 0; i < n; i++) {
const a = s.slice(i, n)
if (res < a) res = a
}
return res
}
test.each([
{ input: { s: 'abab' }, output: 'bab' },
{ input: { s: 'leetcode' }, output: 'tcode' },
])('input: s = $input.s', ({ input: { s }, output }) => {
expect(lastSubstring(s)).toEqual(output)
})