1.Give the first character of *s* to *part*.

2.Find out the longest substring without repeating characters.

3.return the length.

```
public class Solution {
public int lengthOfLongestSubstring(String s) {
if(s.length()==0) return 0;
if(s.length()==1) return 1;
int length=0;
String part=""+s.charAt(0);
for(int i=1;i<s.length();i++)
{
if(part.indexOf(s.charAt(i))==-1)
{
part=part+s.charAt(i);
}
else
{
int index=part.indexOf(s.charAt(i));
if(part.length()>length)
{
length=part.length();
}
part=part.substring(index+1);
i--;
}
}
return part.length()>length?part.length():length;
}
}
```