I think my java code is O(n). But I always get TLE on the longest test cases.

I also tried to all the accepted java solution from Discuss to OJ, but all of them got TLE.

I guess that leetcode OJ may has some problem on java. Please check it.

```
public class Solution {
public boolean isOneEditDistance(String s, String t) {
int m=s.length();
int n=t.length();
if(m>n){
return isOneEditDistance(t,s);
}
if(m==n){
int count=0;
for(int i=0;i<n;i++){
if(s.charAt(i)!=t.charAt(i)){
count++;
}
}
return count==1;
}else if(m==n-1){
int count=0;
int i=0;
while(i<m){
if(s.charAt(i)!=t.charAt(i)){
return s.substring(i, m).equals(t.substring(i+1, n));
}
i++;
}
return true;
}
return false;
}
}
```