字节跳动面试题之最大连续字符串

要求从一个字符串中寻找一个子字符串,要求是,连续,没有重复字符!

 

使用golang实现代码:

package main

import "fmt"

func main() {
   var str = "abccabcdeeabcdefgj1234"
   var r = ""
   for i := 0; i < len(str); i++ {
      var current = str[i : i+1]
      for j := 0; j < len(r); j++ {
         if r[j:j+1] == current {
            r = ""
         }
      }
      r += current
   }
   fmt.Println(r)
}