1. func lengthOfLongestSubstring(s string) int {
    2. if s == "" {
    3. return 0
    4. }
    5. max := 0
    6. for i := 0; i < len(s); i++ {
    7. start := 0
    8. num := 0
    9. lens := len(s)
    10. hashmap := map[byte]int{}
    11. for true {
    12. if hashmap[s[start+i]] == 1 {
    13. break
    14. }
    15. hashmap[s[start+i]] = 1
    16. start++
    17. num++
    18. if start + i == lens {
    19. break
    20. }
    21. }
    22. if num > max {
    23. max = num
    24. }
    25. }
    26. return max
    27. }