2023-08-18:用go写算法。你会

2023-08-18:用go写算法。你会得到一个字符串 text,
你应该把它分成 k 个子字符串 (subtext1, subtext2,…, subtextk)。
要求满足:
subtexti 是 非空 字符串,
所有子字符串的连接等于 text ,
( 即subtext1 + subtext2 + ... + subtextk == text ),
subtexti == subtextk - i + 1 表示所有 i 的有效值( 即 1 <= i <= k )。
返回k可能最大值。
输入:text = &quot;ghiabcdefhelloadamhelloabcdefghi&quot;。
输出:7。
解释:我们可以把字符串拆分成 &quot;(ghi)(abcdef)(hello)(adam)(hello)(abcdef)(ghi)&quot;。
#福大大架构师每日一题#
#Go语言#
2023-08-18
在牛客打卡883天,今天也很努力鸭!
全部评论

相关推荐

08-23 10:20
湘南学院 Java
点赞 评论 收藏
分享
1 1 评论
分享
牛客网
牛客企业服务