# 第二十三周ARTS总结
# Algorithm
0ms | 100.00% Run time
37.7MB | 67.94% Memory
public int strStr(String haystack, String needle) {
// needle is a empty string
if (needle == null || needle.length() == 0) {
return 0;
}
// needle比haystack长
if (haystack == null || haystack.length() < needle.length()) {
return -1;
}
for (int i = 0; i <= haystack.length() - needle.length(); i++) {
String sub = haystack.substring(i, i + needle.length());
if (needle.equals(sub)) {
return i;
}
}
return -1;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Review
# Tip
ScrollView
和fitsSystemWindows
一起使用能够有效的处理EditText
和软键盘的显示- 当给
View
设置背景为虚线时,宽度需要大于虚线的宽度,否则会显示不了虚线 ViewPage
默认会加载本身和左右的Fragment
,会销毁不相邻的Fragment
# Share
暂无内容