# What if the input are not 2 strings, but 2 char streams?

• My code is pasted below, it's accepted, but what if the inputs are 2 char steams? Then we couldn't compare the length, so how to solve the problem? Anyone has a idea?

public class Solution {

``````public boolean isOneEditDistance(String s, String t) {
int len1=s.length(), len2=t.length();
if(Math.abs(len1-len2)>=2) return false;
if(len1-len2==1) return isOneLengthDiff(s,t);
else if(len2-len1==1) return isOneLengthDiff(t,s);
else return isSameLength(s,t);
}
public boolean isOneLengthDiff(String s, String t){
for(int i=0; i<t.length(); i++){
if(s.charAt(i)==t.charAt(i)) continue;
return s.substring(i+1).equals(t.substring(i));
}
return true;
}
public boolean isSameLength(String s, String t){
for(int i=0; i<s.length(); i++){
if(s.charAt(i)==t.charAt(i)) continue;
return s.substring(i+1).equals(t.substring(i+1));
}
return false;
}
``````

}

• flying LCS? use final LCS to judge

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.