好未来笔试
好未来这个笔试题难度还可以,比较常规,对我这种菜鸡很友好,基础平台开发&3D图形算法-第一套 14:00-15:30那一场,三道算法a了2.6
- 版本号大小判断,过了60%,有没有好giegie帮看一下哪里出了问题
- 三数之和,升序排列一下,转换成两数之和的问题就可以
- 链表整体后移k个单位,其实就是找到倒数第k个节点,断开,把前面的元素接在尾节点后面就可以
package main import ( "fmt" "strings" ) func main() { var first, second string // fmt.Print("请输入") fmt.Scan(&first) fmt.Scan(&second) fmt.Println(first, second) fmt.Println(compare(first, second)) } func compare(first, second string) int { // 以. 进行分割 firs, secs := strings.Split(first, "."), strings.Split(second, ".") //if len(firs) != len(secs) { // return 0 //} for ii := 0; ii < len(firs); ii++ { if ii>=len(secs){ return 1 } fir := firs[ii] sec := secs[ii] // 找到初始的有效位 忽略前置的0 var firstValid, secondValid int //first=strings.ReplaceAll(first,".","") //second=strings.ReplaceAll(second,".","") firBs, secBs := []byte(fir), []byte(sec) for i, b := range firBs { if b == '0' { continue } firstValid = i break } for i, b := range secBs { if b == '0' { continue } secondValid = i break } //if firstValid != secondValid { // return 0 //} for l, r := firstValid, secondValid; ; l, r = l+1, r+1 { if l >= len(firBs) || r >= len(secBs) { break } if firBs[l] < secBs[r] { return -1 } else if firBs[l] > secBs[r] { return 1 } } } return 0 }#好未来笔试讨论##笔经#