fork download
  1. public class Solution {
  2. public int strStr(String haystack, String needle) {
  3. int haySize = haystack.length();
  4. int needSize = needle.length();
  5. if(haySize==0 && needSize==0) return 0;
  6. for(int i=0;i<haySize-needSize+1;i++) {
  7. boolean found = true;
  8. for(int j=0;j<needSize;j++) {
  9. if(haystack.charAt(i+j)!=needle.charAt(j)) {
  10. found = false;
  11. break;
  12. }
  13. }
  14. if(found) return i;
  15. }
  16. return -1;
  17. }
  18. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class Solution is public, should be declared in a file named Solution.java
public class Solution {
       ^
1 error
stdout
Standard output is empty