Skip to content

Instantly share code, notes, and snippets.

@harbirchahal
Last active February 26, 2020 18:20
Show Gist options
  • Save harbirchahal/476a7312b83ae0522f0e05d823abc5de to your computer and use it in GitHub Desktop.
Save harbirchahal/476a7312b83ae0522f0e05d823abc5de to your computer and use it in GitHub Desktop.
Mock implementation of String functions
public class String {
public static boolean contains(String s, String t) {
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == t.charAt(0)) {
int j = 1;
for (; j < t.length(); j++) {
if (t.charAt(j) != s.charAt(i + j)) {
break;
}
}
if (j == t.length()) {
return true;
}
}
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment