## 题目描述：

LeetCode 555. Split Assembled Strings

Given a list of strings, you could assemble these strings together into a loop. Among all the possible loops, you need to find the lexicographically biggest string after cutting and making one breakpoint of the loop, which will make a looped string into a regular one.

So, to find the lexicographically biggest string, you need to experience two phases:

1. Assemble all the strings into a loop, where you can reverse some strings or not and connect them in the same order as given.
2. Cut and make one breakpoint in any place of the loop, which will make a looped string into a regular string starting from the character at the cutting point.

And your job is to find the lexicographically biggest one among all the regular strings.

Example:

```Input: "abc", "xyz"
Output: "zyxcba"
Explanation: You can get the looped string "-abcxyz-", "-abczyx-", "-cbaxyz-", "-cbazyx-",
where '-' represents the looped status.
The answer string came from the third looped one,
where you could cut from the middle and get "zyxcba".
```

Note:

1. The input strings will only contain lowercase letters.
2. The total length of all the strings will not over 1000.

## 题目大意：

1. 输入字符串只包含小写字母
2. 字符串总长度不超过1000

## 解题思路：

```遍历strs中的字符串，若逆置后的字典序较大，则将其逆置

## Python代码：

``````class Solution(object):
def splitLoopedString(self, strs):
"""
:type strs: List[str]
:rtype: str
"""
strs = [max(s, s[::-1]) for s in strs]
ans = ''
for i, st in enumerate(strs):
left, right = ''.join(strs[:i]), ''.join(strs[i+1:])
for s in (st, st[::-1]):
for j in range(len(s)):
ans = max(ans, s[j:] + right + left + s[:j])
return ans
``````

Pingbacks已关闭。