You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
654 B
33 lines
654 B
5 years ago
|
/*
|
||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
|
*
|
||
|
* This source code is licensed under the MIT license found in the
|
||
|
* LICENSE file in the root directory of this source tree.
|
||
|
*/
|
||
|
class StringTest {
|
||
|
|
||
|
String mId;
|
||
|
|
||
|
int indexof_linear(String m) {
|
||
|
return m.indexOf('_');
|
||
|
}
|
||
|
|
||
|
int indexof_from_linear(String m, int j) {
|
||
|
return m.indexOf('_', j);
|
||
|
}
|
||
|
|
||
|
int indexof_quadratic(String m, String n) {
|
||
|
return m.indexOf(n);
|
||
|
}
|
||
|
|
||
|
int indexof_constant(String n) {
|
||
|
String m = "hi";
|
||
|
return m.indexOf('i');
|
||
|
}
|
||
|
|
||
|
public String index_substring_linear() {
|
||
|
int index = indexof_linear(mId);
|
||
|
return mId.substring(0, index);
|
||
|
}
|
||
|
}
|