796. 旋转字符串
原文英文,约400词,阅读约需2分钟。发表于: 。796. Rotate String Difficulty: Easy Topics: String, String Matching Given two strings s and goal, return true if and only if s can become goal after some number of shifts on s. A shift on s...
给定两个字符串s和goal,判断s经过若干次左移后是否能变为goal。可以通过将s与自身连接(s+s)来检查goal是否为其子串,时间复杂度为O(n),空间复杂度为O(n)。