90 lines
1.7 KiB
Go
90 lines
1.7 KiB
Go
package main
|
||
|
||
import "fmt"
|
||
|
||
func main() {
|
||
fmt.Println(minWindow("baABabbb", "A"))
|
||
}
|
||
|
||
func minWindow(s string, t string) string {
|
||
return ""
|
||
}
|
||
|
||
//func minWindow(s string, t string) string {
|
||
// if len(s) < len(t) {
|
||
// return ""
|
||
// }
|
||
// //fmt.Println("1")
|
||
// minstr := ""
|
||
// numstr := make([]int, 256)
|
||
// num := 0
|
||
// for _, ch := range t {
|
||
//
|
||
// //fmt.Println("ch:", ch, 'a')
|
||
// numstr[ch]++
|
||
// num++
|
||
// }
|
||
//
|
||
// for i := 0; i < len(s); i++ {
|
||
// //fmt.Println("1")
|
||
// if int(s[i]) >= len(numstr) {
|
||
// //fmt.Println("2")
|
||
// continue
|
||
// }
|
||
// //fmt.Println("------当前i,", i)
|
||
// //fmt.Println("numstr[s[i]]", numstr[s[i]])
|
||
// if numstr[s[i]] > 0 {
|
||
// tmpnum := num
|
||
// tmpstr := make([]int, 256)
|
||
// copy(tmpstr, numstr)
|
||
// tmpstr[s[i]] -= 1
|
||
// tmpnum--
|
||
// p := i + 1
|
||
// for p < len(s) {
|
||
// if tmpnum == 0 {
|
||
// //fmt.Println("退出循环")
|
||
// break
|
||
// }
|
||
// //fmt.Println("当前p:", p, "指向:", string(s[p]))
|
||
// //fmt.Println("tmpstr", tmpstr)
|
||
// if int(s[p]) >= len(tmpstr) {
|
||
// p++
|
||
// //fmt.Println("跳过")
|
||
// continue
|
||
// }
|
||
//
|
||
// if tmpstr[s[p]] > 0 {
|
||
// tmpstr[s[p]] -= 1
|
||
// tmpnum--
|
||
//
|
||
// //fmt.Println("修改后的tmpstr", tmpstr)
|
||
//
|
||
// }
|
||
// //fmt.Println("1")
|
||
// p++
|
||
// }
|
||
// //fmt.Println("本次循环中tmpnum为:", tmpnum)
|
||
// if tmpnum == 0 {
|
||
// //fmt.Println("匹配到目标")
|
||
// if len(minstr) == 0 {
|
||
// minstr = s[i:p]
|
||
// } else {
|
||
// if (p - i) < len(minstr) {
|
||
// minstr = s[i:p]
|
||
// }
|
||
// }
|
||
//
|
||
// } else {
|
||
// continue
|
||
//
|
||
// }
|
||
//
|
||
// } else {
|
||
// continue
|
||
// }
|
||
// //fmt.Println("------退出第", i, "次循环,minstr为:", minstr)
|
||
// }
|
||
//
|
||
// return minstr
|
||
//}
|