Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 实话实说没觉得特别easy。。
- class Solution {
- public int repeatedStringMatch(String A, String B) {
- if(A == null || B == null) return -1;
- if(B.equals("")) return 1;
- int m = A.length(), n = B.length(), count = 0;
- StringBuilder sb = new StringBuilder();
- while(sb.length() < n)
- {
- sb.append(A);
- count++;
- }
- if(sb.indexOf(B) >= 0) return count;
- if(sb.append(A).indexOf(B) >= 0) return count + 1;
- return -1;
- }
- }
Add Comment
Please, Sign In to add comment