Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add solutions to lc problems: No.3029 #2316

Merged
merged 9 commits into from
Feb 4, 2024
Prev Previous commit
Next Next commit
feat: add solutions to lc problems: No.3029
  • Loading branch information
Nothing-avil authored Feb 4, 2024
commit c04710b64d8295de9f8bd88929ee64d7cfdef3f0
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Solution {
public int minimumTimeToInitialState(String word, int k) {
int n = word.length();
for (int i = 1; i <= 10000; i++) {
int re = i * k;
if (re >= n) {
return i;
}
String str = word.substring(re);
boolean flag = true;
for (int j = 0; j < str.length(); j++) {
if (str.charAt(j) != word.charAt(j)) {
flag = false;
break;
}
}
if (flag) {
return i;
}
}
return 0;
}
}